Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add DNS and TCP reports to test-connectivity #272

Merged
merged 9 commits into from
Sep 20, 2024
Merged

Conversation

fortuna
Copy link
Contributor

@fortuna fortuna commented Sep 4, 2024

@amircybersec Check out this implementation.

I am able to get both TCP and DNS reports, while keeping the main test agnostic to the transport. (Thanks to your httptrace trick!)

image

Thoughts?

@fortuna
Copy link
Contributor Author

fortuna commented Sep 4, 2024

I added timing for DNS, but not TCP yet. It requires a map of net-address to start time.

@amircybersec
Copy link
Contributor

@fortuna I like the proposed approach. It basically makes the context specific to a given dialer which can solve the concurrency issue and provide access to hostname. We can technically refactor this into a reporter dialer that can be used as the baseDialer. We can use the existing approach in complement to this and add do53-udp, do53-tcp, doh, dot, https, quic, etc test reports on the top of this. I am going to take this code for a spin 🚘

@amircybersec
Copy link
Contributor

@fortuna I made a light refactor. I also added start time and duration to TCP connection.

Also, it seems like your branch is on the top of an older version that does not have the recent udp support for socks. I can do a rebase.

2024/09/05 22:03:29 Failed to create PacketDialer: config scheme 'socks5' is not supported for Packet Dialers

@fortuna
Copy link
Contributor Author

fortuna commented Sep 6, 2024

I've moved your changes to #275.

I'm not touching any dependencies in my PR, so if it doesn't have UDP SOCKS5, it's because main doesn't have it.

@fortuna
Copy link
Contributor Author

fortuna commented Sep 6, 2024

Oh, nevermind, I started in an old main

@fortuna
Copy link
Contributor Author

fortuna commented Sep 6, 2024

Ok, my branch is not on top of main @ HEAD

Copy link
Contributor Author

@fortuna fortuna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you have any comments on this

@fortuna
Copy link
Contributor Author

fortuna commented Sep 20, 2024

Now with colored slog!
image

@fortuna fortuna requested a review from jyyi1 September 20, 2024 14:58
Copy link
Contributor

@amircybersec amircybersec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add mutex lock/unlock for dnsReport in UDP too. Other than that, it looks good. I will do a separate PR to add connectStart and Duration to tcpReport after we merge this.

switch proto {
case "tcp":
configToDialer := config.NewDefaultConfigToDialer()
configToDialer.BaseStreamDialer = transport.FuncStreamDialer(func(ctx context.Context, addr string) (transport.StreamConn, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fortuna I believe we should move setting both udp and tcp base dialers outside of the switch statement. In other words, we should set both udp and tcp base dialer regardless of the selected protocol since for example doing udp resolution over socks5 will do both udp and tcp operations.

In the current implementation, we cannot collect dns report if protocol is set to udp (-proto udp) and if the transport is socks5 since it would use plain tcp dialer which does not have the tracer setup.

You can checkout the changes I made on this branch: https://github.com/Jigsaw-Code/outline-sdk/blob/amir-tc-3/x/examples/test-connectivity/main.go

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you try the cli with -proto udp over socks5 transport you can see that dns and tcp connect report are empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in acdc622

for _, ip := range di.Addrs {
report.AnswerIPs = append(report.AnswerIPs, ip.IP.String())
}
// TODO(fortuna): Use a Mutex.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO(fortuna): Use a Mutex.
mu.Lock()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in acdc622

}
// TODO(fortuna): Use a Mutex.
dnsReports = append(dnsReports, report)
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
},
mu.Unlock()
},

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in acdc622

@fortuna fortuna merged commit f65586c into main Sep 20, 2024
6 checks passed
@fortuna fortuna deleted the fortuna-tc branch September 20, 2024 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants