Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
obfs4-deprecated
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
leap
obfs4-deprecated
Commits
b3d17c32
Commit
b3d17c32
authored
10 years ago
by
Yawning Angel
Browse files
Options
Downloads
Patches
Plain Diff
Validate the host component of the proxy URI.
Part of issue #7.
parent
d5c3a25d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
obfs4proxy/pt_extra.go
+33
-0
33 additions, 0 deletions
obfs4proxy/pt_extra.go
with
33 additions
and
0 deletions
obfs4proxy/pt_extra.go
+
33
−
0
View file @
b3d17c32
...
...
@@ -30,8 +30,10 @@ package main
import
(
"errors"
"fmt"
"net"
"net/url"
"os"
"strconv"
"git.torproject.org/pluggable-transports/goptlib"
)
...
...
@@ -131,5 +133,36 @@ func ptGetProxy() (*url.URL, error) {
return
nil
,
ptProxyError
(
fmt
.
Sprintf
(
"proxy URI has invalid scheme: %s"
,
spec
.
Scheme
))
}
err
=
validateAddrStr
(
spec
.
Host
)
if
err
!=
nil
{
return
nil
,
ptProxyError
(
fmt
.
Sprintf
(
"proxy URI has invalid host: %s"
,
err
))
}
return
spec
,
nil
}
// Sigh, pt.resolveAddr() isn't exported. Include our own getto version that
// doesn't work around #7011, because we don't work with pre-0.2.5.x tor, and
// all we care about is validation anyway.
func
validateAddrStr
(
addrStr
string
)
error
{
ipStr
,
portStr
,
err
:=
net
.
SplitHostPort
(
addrStr
)
if
err
!=
nil
{
return
err
}
if
ipStr
==
""
{
return
net
.
InvalidAddrError
(
fmt
.
Sprintf
(
"address string %q lacks a host part"
,
addrStr
))
}
if
portStr
==
""
{
return
net
.
InvalidAddrError
(
fmt
.
Sprintf
(
"address string %q lacks a port part"
,
addrStr
))
}
if
net
.
ParseIP
(
ipStr
)
==
nil
{
return
net
.
InvalidAddrError
(
fmt
.
Sprintf
(
"not an IP string: %q"
,
ipStr
))
}
_
,
err
=
strconv
.
ParseUint
(
portStr
,
10
,
16
)
if
err
!=
nil
{
return
net
.
InvalidAddrError
(
fmt
.
Sprintf
(
"not a Port string: %q"
,
portStr
))
}
return
nil
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment