@@ -829,6 +829,8 @@ def fetch_credentials(self, address, session_id, type, conndesc):
829829 return None , None , None
830830
831831 def write_wireguard_config (self , response , decode , wgkey , conndesc , iface ):
832+ CONFIG = MeileConfig .read_configuration (MeileConfig .CONFFILE )
833+ user_dns = CONFIG ['network' ].get ('dns' , '9.9.9.9' )
832834 if len (decode ) < 100 :
833835 self .connected = {
834836 "v2ray_pid" : None ,
@@ -884,7 +886,7 @@ def write_wireguard_config(self, response, decode, wgkey, conndesc, iface):
884886 config .set ("Interface" , "PrivateKey" , wgkey .privkey )
885887 config .set (
886888 "Interface" , "DNS" ,
887- "," .join (["127.0.0.1" , "1.0.0.1" , "1.1.1.1" ])
889+ "," .join ([user_dns , "1.0.0.1" , "1.1.1.1" ])
888890 )
889891
890892 config .add_section ("Peer" )
@@ -1224,46 +1226,39 @@ def connect(self,
12241226 if pltfrm == Arch .LINUX :
12251227 child = pexpect .spawn (f"pkexec sh -c 'ip link delete { iface } ; wg-quick up { config_file } '" )
12261228 child .expect (pexpect .EOF )
1227- ok = wait_for_tunnel_iface (iface = ["wg99" , "utun3" ], timeout = 300 )
1228- if ok is None :
1229- self .connected = {"v2ray_pid" : None ,
1230- "result" : False ,
1231- "status" : "Error bringing up wireguard interface" ,
1232- "session_id" : session_id }
1233- return
1229+
12341230 elif pltfrm == Arch .OSX :
12351231 connectBASH = [sentinel_connect_bash ]
12361232 proc2 = subprocess .Popen (connectBASH )
12371233 proc2 .wait (timeout = 30 )
12381234 pid2 = proc2 .pid
12391235 proc_out , proc_err = proc2 .communicate ()
1240- ok = wait_for_tunnel_iface (iface = ["wg99" , "utun3" ], timeout = 300 )
1241- if ok is None :
1242- self .connected = {"v2ray_pid" : None ,
1243- "result" : False ,
1244- "status" : "Error bringing up wireguard interface" ,
1245- "session_id" : session_id }
1246- return
1236+
12471237 elif pltfrm == Arch .WINDOWS :
12481238 wgup = [gsudo , MeileConfig .WIREGUARD_BIN , "/installtunnelservice" , config_file ]
12491239 wg_process = subprocess .Popen (wgup )
1250- ok = wait_for_tunnel_iface (iface = ["wg99" , "utun3" ], timeout = 300 )
1251- if ok is None :
1252- self .connected = {"v2ray_pid" : None ,
1253- "result" : False ,
1254- "status" : "Error bringing up wireguard interface" ,
1255- "session_id" : session_id }
1256- return
12571240
1258- if psutil .net_if_addrs ().get (iface ) or psutil .net_if_addrs ().get ("utun3" ):
1241+
1242+ #if psutil.net_if_addrs().get(iface) or psutil.net_if_addrs().get("utun3"):
1243+ tuniface = wait_for_tunnel_iface (iface = [iface , "utun3" ], timeout = 30 )
1244+ if tuniface is not None :
12591245 self .connected = {"v2ray_pid" : None ,
12601246 "result" : True ,
1261- "status" : iface ,
1247+ "status" : tuniface ,
12621248 "session_id" : session_id }
12631249 conndesc .write ("Checking network connection...\n " )
12641250 conndesc .flush ()
1265- sleep (1 )
1266- self .get_ip_address ()
1251+ sleep (2 )
1252+ if self .get_ip_address ():
1253+ self .connected = {"v2ray_pid" : None ,
1254+ "result" : True ,
1255+ "status" : tuniface ,
1256+ "session_id" : session_id }
1257+ else :
1258+ self .connected = {"v2ray_pid" : None ,
1259+ "result" : False ,
1260+ "status" : "Error establising connection to internet. Try a differnt node." ,
1261+ "session_id" : session_id }
12671262 sleep (1 )
12681263 conndesc .close ()
12691264 return
@@ -1303,7 +1298,8 @@ def connect(self,
13031298 if pltfrm == Arch .OSX :
13041299 chdir (MeileConfig .BASEDIR )
13051300 return
1306-
1301+
1302+ '''
13071303 if pltfrm != Arch.OSX:
13081304 for iface in psutil.net_if_addrs().keys():
13091305 if "tun" in iface:
@@ -1317,12 +1313,16 @@ def connect(self,
13171313 "session_id" : session_id}
13181314 print(self.connected)
13191315 tuniface = True
1320-
1321- if tuniface is True :
1322- print (self .connected )
1316+ '''
1317+
1318+ tuniface = wait_for_tunnel_iface (iface = ["tun" , "utun3" , "utun123" ], timeout = 30 )
1319+
1320+
1321+ if tuniface is not None :
1322+ print ("Tunnel interface is up:" , tuniface )
13231323 conndesc .write ("Checking network connection...\n " )
13241324 conndesc .flush ()
1325- sleep (1 )
1325+ sleep (3.3 )
13261326 if self .get_ip_address ():
13271327 self .connected = {"v2ray_pid" : v2ray_handler .v2ray_pid ,
13281328 "result" : True ,
0 commit comments