/** Package for the Scol settings This is a part of the 'Scol voyager' ================================= License : This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt Author : Bastien Bourineau */ // NETWORKING Setup interface structure struct NETSETUPstr = [ NETSETUP_WIN : ObjWin, NETSETUP_INFO : ObjText, NETSETUP_LABEL : ObjText, NETSETUP_CONFWIN : ObjWin, NETSETUP_AUTOCHK : ObjCheck, NETSETUP_HTTPPROXYLABEL : ObjText, NETSETUP_HTTPPROXY : ObjText, NETSETUP_SOCKSPROXYLABEL : ObjText, NETSETUP_SOCKSPROXY : ObjText, NETSETUP_MASKPROXYLABEL : ObjText, NETSETUP_MASKPROXY : ObjText, NETSETUP_SOCKS4 : ObjCheck, NETSETUP_SOCKS5 : ObjCheck, NETSETUP_AUTH : ObjCheck, NETSETUP_NAMELABEL : ObjText, NETSETUP_NAME : ObjText, NETSETUP_PASSLABEL : ObjText, NETSETUP_PASS : ObjText, NETSETUP_IPLABEL : ObjText, NETSETUP_IPCOMBO : ObjBox ] mkNETSETUPstr;; typeof SETUP_NETWORK = NETSETUPstr;; /* ********************************************************************************************* / Setup Network Interface / ********************************************************************************************* */ fun saveSetupNetwork()= let _GETcheck SETUP_NETWORK.NETSETUP_AUTOCHK -> auto in if (SETUP_NETWORK == nil) then nil else ( chgress "AutodetectProxy" if auto then "Yes" else "No"; chgusm "HTTPproxy" nil let strbuild ("HTTPproxy"::(if auto then nil else _GETtext SETUP_NETWORK.NETSETUP_HTTPPROXY)::nil)::nil -> s in substr s 0 (strlen s)-1; chgress "ProxySocks" if auto then nil else _GETtext SETUP_NETWORK.NETSETUP_SOCKSPROXY; chgress "ProxyMask" if auto then nil else _GETtext SETUP_NETWORK.NETSETUP_MASKPROXY; /* socks5 parameters save */ chgress "SocksVer" if (_GETcheck SETUP_NETWORK.NETSETUP_SOCKS4) then "4" else "5"; chgress "Socks5Authentication" if (_GETcheck SETUP_NETWORK.NETSETUP_AUTH) then "yes" else "no"; chgusm "Socks5Uname" nil let strbuild ("Socks5Uname"::(_GETtext SETUP_NETWORK.NETSETUP_NAME)::nil)::nil -> s in substr s 0 (strlen s)-1; chgusm "Socks5Pword" nil let strbuild ("Socks5Pword"::(_GETtext SETUP_NETWORK.NETSETUP_PASS)::nil)::nil -> s in substr s 0 (strlen s)-1; ); 0;; fun cbSetupSocksAuth(chk, p, state)= if (state == 1) then ( _ENtext SETUP_NETWORK.NETSETUP_NAMELABEL 1; _ENtext SETUP_NETWORK.NETSETUP_PASSLABEL 1; _ENtext SETUP_NETWORK.NETSETUP_NAME 1; _ENtext SETUP_NETWORK.NETSETUP_PASS 1; 1; ) else ( _ENtext SETUP_NETWORK.NETSETUP_NAMELABEL 0; _ENtext SETUP_NETWORK.NETSETUP_PASSLABEL 0; _ENtext SETUP_NETWORK.NETSETUP_NAME 0; _ENtext SETUP_NETWORK.NETSETUP_PASS 0; 1; ); 0;; fun cbSetupSocksVers(chk, ver, state)= if (ver == 4) then ( _ENcheck SETUP_NETWORK.NETSETUP_AUTH 0; cbSetupSocksAuth SETUP_NETWORK.NETSETUP_AUTH nil 0; 1; ) else ( _ENcheck SETUP_NETWORK.NETSETUP_AUTH 1; cbSetupSocksAuth SETUP_NETWORK.NETSETUP_AUTH nil _GETcheck SETUP_NETWORK.NETSETUP_AUTH; 1; ); 0;; fun setupSocksNetwork (auto) = let _autodetectproxy ->[autohttp autosocks automask] in if (auto && ((autosocks == nil) || (!strcmp autosocks "") || (!strcmpi autosocks "no"))) then ( _SETcheck SETUP_NETWORK.NETSETUP_SOCKS4 0; _ENcheck SETUP_NETWORK.NETSETUP_SOCKS4 0; _SETcheck SETUP_NETWORK.NETSETUP_SOCKS5 0; _ENcheck SETUP_NETWORK.NETSETUP_SOCKS5 0; _SETcheck SETUP_NETWORK.NETSETUP_AUTH 0; _ENcheck SETUP_NETWORK.NETSETUP_AUTH 0; _ENtext SETUP_NETWORK.NETSETUP_NAMELABEL 0; _ENtext SETUP_NETWORK.NETSETUP_NAME 0; _ENtext SETUP_NETWORK.NETSETUP_PASSLABEL 0; _ENtext SETUP_NETWORK.NETSETUP_PASS 0; 1; ) else ( _SHOWwindow SETUP_NETWORK.NETSETUP_CONFWIN WINDOW_UNHIDDEN; _ENcheck SETUP_NETWORK.NETSETUP_SOCKS4 1; _ENcheck SETUP_NETWORK.NETSETUP_SOCKS5 1; /* socks 5 authentication initialization */ let _getress "Socks5Authentication" -> socksAuthentication in if ((socksAuthentication != nil) && (!strcmpi socksAuthentication "yes")) then ( _SETcheck SETUP_NETWORK.NETSETUP_AUTH 1; cbSetupSocksAuth SETUP_NETWORK.NETSETUP_AUTH nil 1; ) else ( _SETcheck SETUP_NETWORK.NETSETUP_AUTH 0; cbSetupSocksAuth SETUP_NETWORK.NETSETUP_AUTH nil 0; ); /* socks version initialization */ let _getress "SocksVer" -> socksVer in if ((socksVer != nil) && (!strcmp socksVer "5")) then ( _SETcheck SETUP_NETWORK.NETSETUP_SOCKS4 0; _SETcheck SETUP_NETWORK.NETSETUP_SOCKS5 1; cbSetupSocksVers SETUP_NETWORK.NETSETUP_SOCKS5 5 1; ) else ( _SETcheck SETUP_NETWORK.NETSETUP_SOCKS4 1; _SETcheck SETUP_NETWORK.NETSETUP_SOCKS5 0; cbSetupSocksVers SETUP_NETWORK.NETSETUP_SOCKS4 4 1; ); 1; );; fun cbSetupAutoNetwork(chk, p, state)= if state then ( let _autodetectproxy ->[autohttp autosocks automask] in ( _SETtext SETUP_NETWORK.NETSETUP_HTTPPROXY autohttp; _SETtext SETUP_NETWORK.NETSETUP_SOCKSPROXY autosocks; _SETtext SETUP_NETWORK.NETSETUP_MASKPROXY automask; ); _SHOWwindow SETUP_NETWORK.NETSETUP_CONFWIN WINDOW_HIDDEN; 0; ) else ( _SHOWwindow SETUP_NETWORK.NETSETUP_CONFWIN WINDOW_UNHIDDEN; 0; ); setupSocksNetwork state; saveSetupNetwork; 0;; fun cbComboLocalIp(cmb, p, pos, name)= chgress "localIPindex" (itoa _setLocalIPnumber pos); 0;; // ADD local ips to combo fun addcomboIP(a,b)=_ADDcombo b 100 a;; fun cbSetupCrNetwork(strSetup)= let !strcmpi _getress "AutodetectProxy" "yes" -> auto in let _autodetectproxy ->[autohttp autosocks automask] in ( set SETUP_NETWORK = mkNETSETUPstr [nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil]; set SETUP_NETWORK.NETSETUP_WIN = _CRwindow _channel strSetup.SETUP_WIN 210 10 iSetupChildW iSetupChildH WN_CHILDINSIDE|WN_NOCAPTION ""; set SETUP_NETWORK.NETSETUP_INFO = _CRtext _channel SETUP_NETWORK.NETSETUP_WIN 10 10 (iSetupChildW - 20) 50 ET_ALIGN_LEFT loc "CONFNETMESS"; set SETUP_NETWORK.NETSETUP_IPLABEL = _CRtext _channel SETUP_NETWORK.NETSETUP_WIN 10 70 (iSetupChildW - 20) 20 ET_ALIGN_LEFT|ET_BORDER loc "CONFNETLABEL1"; set SETUP_NETWORK.NETSETUP_IPCOMBO = _CBcombo _CRcombo _channel SETUP_NETWORK.NETSETUP_WIN 10 95 200 120 CB_NOEDIT "" @cbComboLocalIp nil; set SETUP_NETWORK.NETSETUP_LABEL = _CRtext _channel SETUP_NETWORK.NETSETUP_WIN 10 125 (iSetupChildW - 20) 20 ET_ALIGN_LEFT|ET_BORDER loc "CONFNETLABEL2"; set SETUP_NETWORK.NETSETUP_AUTOCHK = _CBcheck _CRcheck _channel SETUP_NETWORK.NETSETUP_WIN 10 150 (iSetupChildW - 20) 20 CH_TABFOCUS loc "CONFNETAUTO" @cbSetupAutoNetwork nil; set SETUP_NETWORK.NETSETUP_CONFWIN = _CRwindow _channel SETUP_NETWORK.NETSETUP_WIN 10 175 (iSetupChildW - 22) (iSetupChildH - 190) (if auto then WN_CHILDINSIDE|WN_NOCAPTION|WN_HIDDEN else WN_CHILDINSIDE|WN_NOCAPTION) ""; set SETUP_NETWORK.NETSETUP_HTTPPROXYLABEL = _CRtext _channel SETUP_NETWORK.NETSETUP_CONFWIN 10 10 120 20 ET_ALIGN_LEFT loc "CONFNETHTTP"; set SETUP_NETWORK.NETSETUP_HTTPPROXY = _CReditLine _channel SETUP_NETWORK.NETSETUP_CONFWIN 135 10 120 20 ET_ALIGN_LEFT|ET_BORDER|ET_AHSCROLL (if auto then autohttp else hd getInfos (strextr _loadusmini nil) "HTTPproxy"); set SETUP_NETWORK.NETSETUP_SOCKSPROXYLABEL = _CRtext _channel SETUP_NETWORK.NETSETUP_CONFWIN 10 35 120 20 ET_ALIGN_LEFT loc "CONFNETSOCKS"; set SETUP_NETWORK.NETSETUP_SOCKSPROXY = _CReditLine _channel SETUP_NETWORK.NETSETUP_CONFWIN 135 35 120 20 ET_ALIGN_LEFT|ET_BORDER|ET_AHSCROLL if auto then autosocks else _getress "ProxySocks"; set SETUP_NETWORK.NETSETUP_MASKPROXYLABEL = _CRtext _channel SETUP_NETWORK.NETSETUP_CONFWIN 10 60 120 20 ET_ALIGN_LEFT loc "CONFNETMASK"; set SETUP_NETWORK.NETSETUP_MASKPROXY = _CReditLine _channel SETUP_NETWORK.NETSETUP_CONFWIN 135 60 120 20 ET_ALIGN_LEFT|ET_BORDER|ET_AHSCROLL if auto then automask else _getress "ProxyMask"; /**********************/ /* SOCKS parameters */ /**********************/ set SETUP_NETWORK.NETSETUP_SOCKS4 = _CBcheck _CRcheck _channel SETUP_NETWORK.NETSETUP_CONFWIN 10 100 (iSetupChildW - 20) 20 CH_TABFOCUS|CH_RADIO loc "CONFNETSOCKS4" @cbSetupSocksVers 4; set SETUP_NETWORK.NETSETUP_SOCKS5 = _CBcheck _CRcheck _channel SETUP_NETWORK.NETSETUP_CONFWIN 10 125 (iSetupChildW - 20) 20 CH_TABFOCUS|CH_RADIO loc "CONFNETSOCKS5" @cbSetupSocksVers 5; set SETUP_NETWORK.NETSETUP_AUTH = _CBcheck _CRcheck _channel SETUP_NETWORK.NETSETUP_CONFWIN 10 155 (iSetupChildW - 20) 20 CH_TABFOCUS loc "CONFNETAUTH" @cbSetupSocksAuth nil; set SETUP_NETWORK.NETSETUP_NAMELABEL = _CRtext _channel SETUP_NETWORK.NETSETUP_CONFWIN 10 180 120 20 ET_ALIGN_LEFT loc "CONFNETLOGIN"; let hd getInfos (strextr _loadusmini nil) "Socks5Uname" -> uname in let if (uname == nil) then "" else uname -> uname in set SETUP_NETWORK.NETSETUP_NAME = _CReditLine _channel SETUP_NETWORK.NETSETUP_CONFWIN 135 180 120 20 ET_ALIGN_LEFT|ET_BORDER|ET_AHSCROLL uname; set SETUP_NETWORK.NETSETUP_PASSLABEL = _CRtext _channel SETUP_NETWORK.NETSETUP_CONFWIN 10 205 120 20 ET_ALIGN_LEFT loc "CONFNETPASS"; let hd getInfos (strextr _loadusmini nil) "Socks5Pword" -> pword in let if (pword == nil) then "" else pword -> pword in set SETUP_NETWORK.NETSETUP_PASS = _CReditLine _channel SETUP_NETWORK.NETSETUP_CONFWIN 135 205 120 20 ET_ALIGN_LEFT|ET_BORDER|ET_AHSCROLL|ET_PASSWORD pword; _SETcheck SETUP_NETWORK.NETSETUP_AUTOCHK auto; apply_on_list _hostIPall @addcomboIP SETUP_NETWORK.NETSETUP_IPCOMBO; _SELcombo SETUP_NETWORK.NETSETUP_IPCOMBO let atoi _getress "localIPindex" -> n in if n==nil || n==-1 then (chgress "localIPindex" "0";0) else n; setupSocksNetwork auto; ); 0;; fun dsSetupNetwork()= saveSetupNetwork; _DSwindow SETUP_NETWORK.NETSETUP_WIN; set SETUP_NETWORK = nil; 0;; fun loadSetupNetwork(strSetup)= addSetupMenu loc "CONFNET" (mkfun1 @cbSetupCrNetwork strSetup) @dsSetupNetwork; 0;;