-
Notifications
You must be signed in to change notification settings - Fork 7
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: streamline support of obfs4 dialer #31
Open
ainghazal
wants to merge
15
commits into
ooni:main
Choose a base branch
from
ainghazal:feat/obfs4-dialer-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e633a4b
feat: streamline support of obfs4 dialer
ainghazal def42d8
hardcode dial timeout seconds
ainghazal 56b85dd
split responsibility in maybeWrapDialerForObfuscation
ainghazal 7e470d1
refactor: satisfy model.Dialer
ainghazal c708ad4
go mod tidy
ainghazal 421bd84
adapt to new signature for tun
ainghazal 381389a
pass around pointer to ProxyNode
ainghazal 987e633
do not ignore old obfs4vpn binary
ainghazal 9dea6ff
raise default timeout for dialer
ainghazal 225ed74
add tests for proxynode constructor
ainghazal c7c4010
qualify todo
ainghazal aef9951
cosmetic changes
ainghazal 028dca7
feat: use a cancellable dialer
ainghazal d428a81
docs: add note
ainghazal 5c0ba78
feat(obfs4): report consistent error for ntor auth mismatch
ainghazal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
minivpn | ||
./obfs4vpn | ||
ndt7 | ||
./vpnping | ||
./geturl | ||
ndt7 | ||
*.swp | ||
*.swo | ||
*.pem | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package obfs4 | ||
|
||
import ( | ||
"errors" | ||
"net/url" | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestNewProxyNodeFromURI(t *testing.T) { | ||
type args struct { | ||
uri string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want *ProxyNode | ||
wantErr error | ||
}{ | ||
{ | ||
name: "empty uri returns error", | ||
args: args{""}, | ||
want: &ProxyNode{}, | ||
wantErr: errBadProxyURI, | ||
}, | ||
{ | ||
name: "bad scheme returns error", | ||
args: args{"http://server/"}, | ||
want: &ProxyNode{}, | ||
wantErr: errBadProxyURI, | ||
}, | ||
{ | ||
name: "file scheme returns error", | ||
args: args{"file://foo/bar/baz"}, | ||
want: &ProxyNode{}, | ||
wantErr: errBadProxyURI, | ||
}, | ||
{ | ||
name: "empty port returns error", | ||
args: args{"obfs4://foo/bar/baz"}, | ||
want: &ProxyNode{}, | ||
wantErr: errBadProxyURI, | ||
}, | ||
{ | ||
name: "empty hostname returns error", | ||
args: args{"obfs4://:222/bar/baz"}, | ||
want: &ProxyNode{}, | ||
wantErr: errBadProxyURI, | ||
}, | ||
{ | ||
name: "happy path does not return error", | ||
args: args{"obfs4://proxy:4444?cert=deadbeef&iat-mode=0"}, | ||
want: &ProxyNode{ | ||
Addr: "proxy:4444", | ||
Protocol: "obfs4", | ||
url: func() *url.URL { | ||
u, _ := url.Parse("obfs4://proxy:4444?cert=deadbeef&iat-mode=0") | ||
return u | ||
}(), | ||
Values: url.Values(map[string][]string{ | ||
"cert": []string{"deadbeef"}, | ||
"iat-mode": []string{"0"}, | ||
}), | ||
}, | ||
wantErr: nil, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := NewProxyNodeFromURI(tt.args.uri) | ||
if !errors.Is(err, tt.wantErr) { | ||
t.Errorf("NewProxyNodeFromURI() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("NewProxyNodeFromURI() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not seem to be checking whether a port is defined here, so what happens if you pass a URL that does not have any port? Also,
u.Host
is equivalent tou.Hostname()
when there is a port.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, and good catch. It should fail if no port is specified, there's no way to assign a default port.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added test for the constructor, and checked for missing port, hostname