rootkiwi / an2linuxserver

Sync Android notifications encrypted to a Linux desktop
Other
402 stars 43 forks source link

Can't pairing when "server-side" is on a VPN. #15

Open Louisina-TSS opened 7 years ago

Louisina-TSS commented 7 years ago

Hello,

My laptop is currently connected to a VPN.

I'm trying to pairing my phone with my laptop trough my eth0 interface (without trough VPN). I checked my router, opened the 46352port on my firewall, and checked my ISP IP address, but I had a timeout on my phone when I tried to pairing.

It's look like that the script listen on the VPN interface (default GW) instead of eth0 (or all) interfaces.

(Already try without any VPN connection on a VM, no problem).

rootkiwi commented 7 years ago

Not sure exactly what you mean. Are you trying to use an2linux over internet?

If you are on LAN then you would just use the LAN ip, it does not matter if VPN is connected or not.

When you connect to the vpn all traffic to internet will be routed through the vpn which is why you can not connect with the external ISP ip. I'm no expert in this but maybe you could mess with the routing table or something for it to work.

Or maybe your vpn provider have port forwarding as a feature then you could use your public VPN ip and connect with that with the port that you've opened with your vpn provider.

Louisina-TSS commented 7 years ago

Yes, I was trying to use an2linux over internet.

In normal case, a program/script respond on the same interface of the request (for example, respond with eth0 if the request is on eth0). I think the script doesn't listen all interface, but only the "default" interface (set to vpn while connected).

For instance, my laptop is always connected to a VPN, but I still can use my ISP address to join my laptop trough ssh or sftp (for example from my phone, or another house). The connection request is on eth0, so the laptop will respond with his eth0 interface, even if a vpn is connected).

Two options to "resolve" this, is:

  1. route table, redirect my phone IP to a specific GW (but if the script listen on the wrong interface, he just can't receive the phone request)
  2. use port-forwarding to make a weird "46352port on eth0 interface to 46352port on vpn interface" but it's weird and can can't work.

Another idea, is use the "LAN" stuff: Connect the client and the server on a VPN with client-to-client enabled and use the "trough LAN". It can work, but well... Need to setup a custom VPN.

rootkiwi commented 7 years ago

I think that when I bind to an empty string as address it will use INADDR_ANY which means:

When INADDR_ANY is specified in the bind call, the socket will be bound to all local interfaces Source: http://man7.org/linux/man-pages/man7/ip.7.html

And I can connect over internet through my VPN that offers port forwarding with tun0 interface and at the same time I can connect over LAN on my eth0 interface.

But I know very little about this, I'm kinda new to both programming and especially socket/network programming. I'm learning as I go :)

You probably know more about this than me, so sorry I don't know what the problem is, if there is something I could change with the program or not.