def mailUser(_): # Mail the key to the person if data['mailKey']: files = [ '/etc/openvpn/keys/%s.csr' % name, '/etc/openvpn/keys/%s.crt' % name, '/etc/openvpn/keys/%s.key' % name, '/etc/openvpn/keys/ca.crt', '/tmp/TCS.ovpn', '/usr/local/tcs/tums/packages/openvpn-install.exe' ] tempconf = """client dev tap proto udp remote tcs-gw.%s port 1194 resolv-retry infinite redirect-gateway def1 nobind persist-key persist-tun ca ca.crt cert %s.crt key %s.key comp-lzo verb 3 keepalive 10 360 tls-timeout 300""" % (self.sysconf.ExternalName, name, name) l = open('/tmp/TCS.ovpn', 'wt') l.write(tempconf) l.close() mailtext = """Your TCS VPN account has been created. Please see the attached files to configure your VPN. Save all the attached files to a folder on your computer and run the attached openvpn-install.exe program. Copy the rest of the attachments to this email to the folder C:\\Program Files\\OpenVPN\\config\\ To connect to the VPN find the icon in the system tray of two red computers, and double click on it. You may be required to edit the TCS.ovpn file, and replace the address on the line "remote %s" with the external address of your server. Should you have any trouble following these instructions please contact Thusa at [email protected] or via telephone at +27 31 277 1250.""" % (self.sysconf.ExternalName,) try: Utils.sendMail("TCS Server <root@%s>" % Settings.defaultDomain, [data['mail']], self.text.vpnConfigDetails, mailtext, files) except Exception, c: print c Utils.exceptionOccured(c) return url.root.child('VPN')
def render_treeView(self, ctx, data): try: T = Tree.Tree("r", "Domains") l = Tree.retrieveTree(Settings.LDAPServer, Settings.LDAPManager, Settings.LDAPPass, 'o='+Settings.LDAPBase) flatL = Tree.flattenTree(l, 'o='+Settings.LDAPBase) flatL.sort() self.flatFil = [] except Exception, e: flatL = [] Utils.exceptionOccured(e)
def mailUser(_): # Mail the key to the person if data['mailKey']: files = ["/usr/local/tcs/tums/packages/%s-vpn.zip" % name] mailp = """Your Vulani VPN account has been created. Please see the attached files to configure your VPN. Save all the attached files to a folder on your computer and run the attached openvpn-install.exe program. Copy the rest of the attachments to this email and extract the zip file to the folder C:\\Program Files\\OpenVPN\\config\\ To connect to the VPN find the icon in the system tray of two red computers, and double click on it. You may be required to edit the TCS.ovpn file, and replace the address on the line "remote %s" with the external address of your server. Should you have any trouble following these instructions please contact [email protected] or by telephone at +27 31 277 1250. """ % (sysconf.ExternalName, ) # Recombobulate for syntax sake mailtext = '\n'.join([i.strip() for i in mailp.split('\n')]) try: return Utils.sendMail( "Vulani <nobody@%s>" % Settings.defaultDomain, [data['mail']], myLang.vpnConfigDetails, mailtext, files).addBoth(callback) except Exception, c: print c return Utils.exceptionOccured(c) return callback(None)