ntop / n2n

Peer-to-peer VPN
GNU General Public License v3.0
6.14k stars 928 forks source link

Problems when using python to run edge.exe on windows #1070

Closed Klutton closed 1 year ago

Klutton commented 1 year ago

I am trying to make a authenticating program via python to identify the device and then connect the devices through n2n in a more easy way

However, I have tried serveral ways to run the system command but all failed

The connection wnt well as the server showed that the edge had been assigned, and no retries showed that the connection was stable.

But when using

ping 10.134.100.x

the requests were all rejected.

I was wondering if there are permissions in my program, please tell me the solution if possible( even changing another programming language)

codes

I using this to ask for administrator permission

def is_admin():
    try:
        return ctypes.windll.shell32.IsUserAnAdmin()
    except:
        return False

if not is_admin():
    ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)
    exit()

I have tried the following methods to start edge.exe

os.system(f'powershell.exe -c ".\edge.exe -c NETWORKS -l {orserver}:{res["port"]} -k {randkey()}"')
subprocess.run([f'.\edge.exe', '-c', group, '-l', f'{orserver}:{res["port"]}', '-k', randkey()],shell=True, stdout=1)
os.system(f'.\edge.exe -c NETWORKS -l {orserver}:{res["port"]} -k {randkey()}')
Klutton commented 1 year ago

After figuring the problem, I found that the -k parameter should be a specific string, I used this in a wrong way which caused the problem. Now this comment should be closed.