Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
briar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Julian Dehm
briar
Commits
da9cde08
Unverified
Commit
da9cde08
authored
8 years ago
by
akwizgran
Browse files
Options
Downloads
Patches
Plain Diff
Include description of SOCKS error in exception.
parent
be3752bf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bramble-core/src/main/java/org/briarproject/bramble/socks/SocksSocket.java
+20
-5
20 additions, 5 deletions
...main/java/org/briarproject/bramble/socks/SocksSocket.java
with
20 additions
and
5 deletions
bramble-core/src/main/java/org/briarproject/bramble/socks/SocksSocket.java
+
20
−
5
View file @
da9cde08
...
...
@@ -12,6 +12,18 @@ import java.net.SocketAddress;
class
SocksSocket
extends
Socket
{
private
static
final
String
[]
ERRORS
=
{
"Succeeded"
,
"General SOCKS server failure"
,
"Connection not allowed by ruleset"
,
"Network unreachable"
,
"Host unreachable"
,
"Connection refused"
,
"TTL expired"
,
"Command not supported"
,
"Address type not supported"
};
private
final
SocketAddress
proxy
;
private
final
int
connectToProxyTimeout
;
...
...
@@ -93,13 +105,16 @@ class SocksSocket extends Socket {
private
void
receiveConnectResponse
(
InputStream
in
)
throws
IOException
{
byte
[]
connectResponse
=
new
byte
[
4
];
IoUtils
.
read
(
in
,
connectResponse
);
byte
version
=
connectResponse
[
0
];
byte
reply
=
connectResponse
[
1
];
byte
addressType
=
connectResponse
[
3
];
int
version
=
connectResponse
[
0
]
&
0xFF
;
int
reply
=
connectResponse
[
1
]
&
0xFF
;
int
addressType
=
connectResponse
[
3
]
&
0xFF
;
if
(
version
!=
5
)
throw
new
IOException
(
"Unsupported SOCKS version: "
+
version
);
if
(
reply
!=
0
)
throw
new
IOException
(
"Connection failed: "
+
reply
);
if
(
reply
!=
0
)
{
if
(
reply
<
ERRORS
.
length
)
throw
new
IOException
(
"Connection failed: "
+
ERRORS
[
reply
]);
else
throw
new
IOException
(
"Connection failed: "
+
reply
);
}
if
(
addressType
==
1
)
IoUtils
.
read
(
in
,
new
byte
[
4
]);
// IPv4
else
if
(
addressType
==
4
)
IoUtils
.
read
(
in
,
new
byte
[
16
]);
// IPv6
else
throw
new
IOException
(
"Unsupported address type: "
+
addressType
);
...
...
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