Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
33a4ebd9
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
33a4ebd9
编写于
3月 13, 2012
作者:
C
chegar
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
80584c90
a63736fd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
24 deletion
+33
-24
test/java/net/Socks/SocksServer.java
test/java/net/Socks/SocksServer.java
+25
-14
test/java/net/Socks/SocksV4Test.java
test/java/net/Socks/SocksV4Test.java
+8
-10
未找到文件。
test/java/net/Socks/SocksServer.java
浏览文件 @
33a4ebd9
...
...
@@ -22,13 +22,14 @@
*/
import
java.net.*
;
import
java.io.*
;
import
java.util.HashMap
;
public
class
SocksServer
extends
Thread
{
// Some useful SOCKS constant
static
final
int
PROTO_VERS4
=
4
;
static
final
int
PROTO_VERS4
=
4
;
static
final
int
PROTO_VERS
=
5
;
static
final
int
DEFAULT_PORT
=
1080
;
static
final
int
DEFAULT_PORT
=
1080
;
static
final
int
NO_AUTH
=
0
;
static
final
int
GSSAPI
=
1
;
...
...
@@ -36,28 +37,28 @@ public class SocksServer extends Thread {
static
final
int
NO_METHODS
=
-
1
;
static
final
int
CONNECT
=
1
;
static
final
int
BIND
=
2
;
static
final
int
BIND
=
2
;
static
final
int
UDP_ASSOC
=
3
;
static
final
int
IPV4
=
1
;
static
final
int
DOMAIN_NAME
=
3
;
static
final
int
IPV6
=
4
;
static
final
int
IPV4
=
1
;
static
final
int
DOMAIN_NAME
=
3
;
static
final
int
IPV6
=
4
;
static
final
int
REQUEST_OK
=
0
;
static
final
int
GENERAL_FAILURE
=
1
;
static
final
int
NOT_ALLOWED
=
2
;
static
final
int
NOT_ALLOWED
=
2
;
static
final
int
NET_UNREACHABLE
=
3
;
static
final
int
HOST_UNREACHABLE
=
4
;
static
final
int
CONN_REFUSED
=
5
;
static
final
int
TTL_EXPIRED
=
6
;
static
final
int
CONN_REFUSED
=
5
;
static
final
int
TTL_EXPIRED
=
6
;
static
final
int
CMD_NOT_SUPPORTED
=
7
;
static
final
int
ADDR_TYPE_NOT_SUP
=
8
;
private
int
port
;
private
ServerSocket
server
;
private
boolean
useV4
=
false
;
private
java
.
util
.
Hashtable
users
=
new
java
.
util
.
Hashtable
();
private
boolean
done
=
false
;
private
HashMap
<
String
,
String
>
users
=
new
HashMap
<>
();
private
volatile
boolean
done
=
false
;
// Inner class to handle protocol with client
// This is the bulk of the work (protocol handler)
class
ClientHandler
extends
Thread
{
...
...
@@ -136,7 +137,7 @@ public class SocksServer extends Thread {
System
.
err
.
println
(
"User: '"
+
uname
);
System
.
err
.
println
(
"PSWD: '"
+
password
);
if
(
users
.
containsKey
(
uname
))
{
String
p1
=
(
String
)
users
.
get
(
uname
);
String
p1
=
users
.
get
(
uname
);
System
.
err
.
println
(
"p1 = "
+
p1
);
if
(
p1
.
equals
(
password
))
{
out
.
write
(
PROTO_VERS
);
...
...
@@ -492,7 +493,12 @@ public class SocksServer extends Thread {
public
SocksServer
(
int
port
)
throws
IOException
{
this
.
port
=
port
;
server
=
new
ServerSocket
();
server
.
bind
(
new
InetSocketAddress
(
port
));
if
(
port
==
0
)
{
server
.
bind
(
null
);
this
.
port
=
server
.
getLocalPort
();
}
else
{
server
.
bind
(
new
InetSocketAddress
(
port
));
}
}
public
SocksServer
()
throws
IOException
{
...
...
@@ -503,8 +509,13 @@ public class SocksServer extends Thread {
users
.
put
(
user
,
passwd
);
}
public
synchronized
void
terminate
()
{
public
int
getPort
()
{
return
port
;
}
public
void
terminate
()
{
done
=
true
;
try
{
server
.
close
();
}
catch
(
IOException
unused
)
{}
}
public
void
run
()
{
...
...
test/java/net/Socks/SocksV4Test.java
浏览文件 @
33a4ebd9
...
...
@@ -26,23 +26,22 @@
* @bug 4727547
* @summary SocksSocketImpl throws NullPointerException
* @build SocksServer
* @run main SocksV4Test
*/
import
java.net.*
;
import
java.io.*
;
public
class
SocksV4Test
{
public
static
void
main
(
String
[]
args
)
throws
IO
Exception
{
// Create a SOCKS V4 proxy
on port 8888
SocksServer
srvr
=
new
SocksServer
(
8888
,
true
);
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// Create a SOCKS V4 proxy
SocksServer
srvr
=
new
SocksServer
(
0
,
true
);
srvr
.
start
();
System
.
setProperty
(
"socksProxyHost"
,
"localhost"
);
System
.
setProperty
(
"socksProxyPort"
,
"8888"
);
Proxy
sp
=
new
Proxy
(
Proxy
.
Type
.
SOCKS
,
new
InetSocketAddress
(
"localhost"
,
srvr
.
getPort
())
);
// Let's create an unresolved address
InetSocketAddress
ad
=
new
InetSocketAddress
(
"doesnt.exist.name"
,
1234
);
Socket
s
=
new
Socket
();
try
{
s
.
connect
(
ad
,
10000
);
try
(
Socket
s
=
new
Socket
(
sp
))
{
s
.
connect
(
ad
,
10000
);
}
catch
(
UnknownHostException
ex
)
{
// OK, that's what we expected
}
catch
(
NullPointerException
npe
)
{
...
...
@@ -50,7 +49,6 @@ public class SocksV4Test {
throw
new
RuntimeException
(
"Got a NUllPointerException"
);
}
finally
{
srvr
.
terminate
();
srvr
.
interrupt
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录