ProxymanApp / atlantis

Capture HTTP/HTTPS, and Websocket from iOS app without proxy.
https://proxyman.io
Apache License 2.0
1.25k stars 93 forks source link

duplicated connection working in an office #119

Open chrisknapp98 opened 1 year ago

chrisknapp98 commented 1 year ago

hi, me and my colleagues are experiencing duplicated connections from atlantis to Proxyman when we are working at the office. Thus, we receive the same network request multiple times with the exact same time, duration etc.

I couldn't find the root of the issue, but filtering in NetServiceTransport#connectToService(_ service: NetService) also gets the job done. Maybe it could be a change to be considered for a future release. Let's see if I manage to create a PR

A problem could be that with that change devices which have the same name couldn't connect both over the network to atlantis

NghiaTranUIT commented 1 year ago

Do you specify the Computer Name when starting the Atlantis Service?

By doing it, Atlantis only connects to this computer, not your colleague's computers.

You can find a name in the Atlantis Windows.

Screenshot_2022-11-15_at_16_39_46

NghiaTranUIT commented 1 year ago

and what Atlantis library version you're using 🤔 ?

chrisknapp98 commented 1 year ago

version 1.19.0

chrisknapp98 commented 1 year ago

The issue is not that it connects to my colleagues computers. No matter if I specify the device in start call, atlantis still keeps connecting multiple times to my Proxyman client. Sometimes it doesn't but often the conection is there like 5 times

chrisknapp98 commented 1 year ago

Okay I haven't got any permissions to push a new branch. But my fix is in line 226 after the guard let hostName to add

        guard !connections.contains(where: { connection in
            if case let NWEndpoint.service(name: connectedHostName, type: _, domain: _, interface: _) = connection.endpoint {
                let splittedHostName = hostName.split(separator: ".")
                let deviceName = splittedHostName.indices.contains(0) ? splittedHostName[0].lowercased() : "DEVICE_NAME"
                if connectedHostName.contains(deviceName) {
                    print("[Atlantis] Found duplicated endpoint")
                }
                return connectedHostName.contains(deviceName)
            }
            return false
        }) else {
            print("[Atlantis] Aborting new connection")
            return
        }
chrisknapp98 commented 1 year ago

ohh I'm just noticing that splitting at a dot and taking index 0 only works with our devices because the host name of our devices always is the serial number with the .local suffix

NghiaTranUIT commented 1 year ago

If you don't mind, please add a checkpoint to this line https://github.com/ProxymanApp/atlantis/blob/a761f2c8a2880b38ff5701e8c0b4e8dacd35c22e/Sources/Transporter.swift#L229

and see how many print output.

If it connect to the same Macbook multiple times, we can see multiple outputs.

chrisknapp98 commented 1 year ago

exactly! That's how I knew atlantis connected to the same device multiple times. Without the guard block I added, this print with the exact same hostName can be seen multiple times. I think this also especially happens when there are like 3+ colleagues in the office which are running Proxyman on their mac

NghiaTranUIT commented 1 year ago

@chrisknapp98 can you try this branch https://github.com/ProxymanApp/atlantis/pull/120?

I refactor a little bit and prevent connecting multiple times to a single Host. I suppose that it can fix the bug.

How to install

Cocoapod

pod 'atlantis-proxyman', :git => 'https://github.com/ProxymanApp/atlantis.git', :commit => '7ee8312b13a6b872a0068bdf11bfc66511614c9f'

SPM

chrisknapp98 commented 1 year ago

seems to be working 👍 I censored the names because it would be the serial numbers

[Atlantis] Looking for Proxyman app in the network...
[Atlantis] 🔎 Found Proxyman at HostName = DEVICE_1.local.
[Atlantis] 🔎 Found Proxyman at HostName = DEVICE_2.local.
[Atlantis] 🔎 Found Proxyman at HostName = DEVICE_3.local.
[Atlantis] ✅ Connect to DEVICE_1.local.
[Atlantis] 🔎 Found Proxyman at HostName = DEVICE_4.local.
[Atlantis] ✅ Connect to DEVICE_2.local.
[Atlantis] ✅ Connect to DEVICE_3.local.
[Atlantis] ✅ Connect to DEVICE_4.local.
[Atlantis] 🔎 Found Proxyman at HostName = DEVICE_1.local.
[Atlantis] ⚠️ Avoid connecting to DEVICE_1.local. because it's already connected!
[Atlantis] Connection established
[Atlantis] Connection established
[Atlantis] Connection established
[Atlantis] Connection established
[Atlantis] 🔎 Found Proxyman at HostName = DEVICE_1.local.
[Atlantis] ⚠️ Avoid connecting to DEVICE_1.local. because it's already connected!
NghiaTranUIT commented 1 year ago

Thanks. Please play around with this update. If it's still working fine, I will release the fix this week 👍

NghiaTranUIT commented 1 year ago

Just a friendly reminder that I've bumped new version 1.20.0, which contains the fix.

However, if you've encountered this bug https://github.com/ProxymanApp/atlantis/issues/121 , Let's try the Proxyman beta build 👍