-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' for version 0.4.0.
0.4.0 with http and https support.
- Loading branch information
Showing
14 changed files
with
177 additions
and
45 deletions.
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
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,65 @@ | ||
> 从校外网络访问USTB校内网络 | ||
![wssocks-ustb v0.3.0](https://img.shields.io/badge/wssocks--ustb-v0.3.0-orange.svg) | ||
|
||
## 使用示例:服务端 | ||
在内网的服务端的主机(如地址为`proxy.gensh.me`的主机)上执行: | ||
```bash | ||
# For instance, listener on port 80. | ||
# And make sure your port has been added to the white list of your firewall. | ||
wssocks server --addr :80 | ||
``` | ||
例如上面的命令,在服务端监听80端口(或者是别的端口,但client端`remote`选项需要和其相一致)。另外,需要确保你监听的端口已经被添加到主机防火墙的白名单列表中。 | ||
|
||
see more: https://github.com/genshen/wssocks#server-side. | ||
|
||
## 使用示例:客户端 | ||
1. 打开命令行,执行如下命令,运行客户端: | ||
> 下面命令中, `wssocks-ustb`可执行程序均指代包含`wssocks-plugin-ustb`插件功能的`wssocks`程序. | ||
```bash | ||
wssocks-ustb client --remote=ws://proxy.gensh.me --vpn-enable --vpn-host=vpn4.ustb.edu.cn --vpn-force-logout --vpn-host-encrypt | ||
``` | ||
以上命令通过启用`--vpn-enable`选项启用通过vpn连接校内到网络。 | ||
随后, 要求输入vpn的用户名和密码登录`n.ustb.edu.cn`以获取其cookie (用户名和密码也可以在命令中通过`--vpn-usernam`和`--vpn-password`选项指定)。 | ||
此外,客户端默认本地监听地址为`:1080`(即0.0.0.0:1080), 服务器端地址为`ws://proxy.gensh.me`。 | ||
|
||
也可以通过`wssocks-ustb client --help`查看更多参数的使用。 其中, 几个主要命令参数如下: | ||
- `--addr` 指定客户端默认本地监听地址,默认为`:1080`(即0.0.0.0:1080); | ||
- `--remote` 指定服务器端地址; | ||
- `--vpn-enable` 是否开启vpn模式;如不开启vpn模式, 将跳过所有以vpn开头的参数; | ||
- `--vpn-host` vpn服务器主机地址; | ||
- `--vpn-username` 登录vpn的用户名;如不在命令参数中指定,将会以交互的方式获取; | ||
- `--vpn-password` 登录vpn的密码; 如不在命令参数中指定,将会以交互的方式获取(为安全起见,不推荐在命令参数中指定); | ||
- `--vpn-force-logout` 如果账号已经在其他设备上登录,强制退出其他设备上的账号; | ||
- `--vpn-host-encrypt` 使用 aes 算法加密代理服务器主机名,默认启用; | ||
|
||
2. 设置代理 | ||
使用socks代理客户端软件(如mac系统的全局代理功能), 设置代理地址。 | ||
![](asserts/mac-proxy.png) | ||
在mac中,勾选**socks代理**选项框, 并填入代理服务器的地址及端口(即wssocks客户端本地监听地址及端口),保存生效。 | ||
如果你使用的是windows, 可以使用[Proxifier](https://www.proxifier.com/)软件。 | ||
(下图proxifier界面来自于 www.proxifier.com , 以展示添加代理方法。使用wssocks时,图中各个字段(如地址和端口)和选项会有区别。) | ||
![proxifier](https://www.proxifier.com/screenshots/proxy.png) | ||
|
||
3. 访问网页 | ||
直接在浏览器地址栏输入对应的地址即可访问,即可访问校内网络,不用任何特殊设置。 | ||
|
||
4. ssh连接(仅macOS) | ||
```bash | ||
ssh -o ProxyCommand='nc -x 127.0.0.1:1080 %h %p' ssh.hpc.gensh.me | ||
``` | ||
![](asserts/ssh-example.png) | ||
windows和linux中可直接使用类似的`ssh ssh.hpc.gensh.me`命令。 | ||
|
||
5. git 命令(仅macOS) | ||
```bash | ||
GIT_SSH_COMMAND="ssh -o ProxyCommand='nc -x 127.0.0.1:1080 %h %p' " git clone repo_address | ||
``` | ||
windows和linux中可直接使用类似的`git clone repo_address`命令。 | ||
|
||
6. 其他终端操作(仅macOS) | ||
```bash | ||
export all_proxy=socks5://127.0.0.1:1080 | ||
git clone repo_address # git clone, 效果同 7. | ||
ssh ssh.hpc.gensh.me # ssh 连接, 效果同6. | ||
``` |
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 |
---|---|---|
@@ -1,28 +1,21 @@ | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/genshen/cmds v0.0.0-20190410131841-986519260a65 h1:RYKhlk6k5qpQBZVaSi+azOINxxJRujYMGHVAdMstw+o= | ||
github.com/genshen/cmds v0.0.0-20190410131841-986519260a65/go.mod h1:Uo2P6VGNS7t++sjm8vO2AqK/AB2v/favOgOZB984Z3o= | ||
github.com/genshen/wssocks v0.2.1 h1:t9mxkZkor+Ov+tDPmtDZErqZck8PfovR2VP4YVcu2a0= | ||
github.com/genshen/wssocks v0.2.1/go.mod h1:orUdoo8chhH0NNlnvs6eZ7RT0r+qnd3dht3vpN02vYQ= | ||
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= | ||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= | ||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= | ||
github.com/genshen/wssocks v0.3.0 h1:AZwaE0yPU2YAIBLsj0ZfAIVdnBOhZFgesbev3rSInRc= | ||
github.com/genshen/wssocks v0.3.0/go.mod h1:300BjgkBxJxQUXHZ6sPKrA2P+RZ0LJ3mlFIu2M9TbWo= | ||
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= | ||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= | ||
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= | ||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= | ||
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/segmentio/ksuid v1.0.2 h1:9yBfKyw4ECGTdALaF09Snw3sLJmYIX6AbPJrAy6MrDc= | ||
github.com/segmentio/ksuid v1.0.2/go.mod h1:BXuJDr2byAiHuQaQtSKoXh1J0YmUDurywOXgB2w+OSU= | ||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= | ||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= | ||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | ||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 h1:1wopBVtVdWnn03fZelqdXTqk7U7zPQCb+T4rbU9ZEoU= | ||
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= | ||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |
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,32 @@ | ||
package ver | ||
|
||
import ( | ||
"errors" | ||
"github.com/genshen/wssocks/wss" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
type PluginVersionNeg struct{} | ||
|
||
func (v *PluginVersionNeg) OnServerVersion(version wss.VersionNeg) error { | ||
log.WithFields(log.Fields{ | ||
"compatible version code": version.CompVersion, | ||
"version code": version.VersionCode, | ||
"wssocks version": version.Version, | ||
}).Info("server version") | ||
|
||
if version.CompVersion > wss.VersionCode || wss.VersionCode > version.VersionCode { | ||
log.WithFields(log.Fields{ | ||
"version code": wss.VersionCode, | ||
"wssocks version": wss.CoreVersion, | ||
}).Info("client version") | ||
return errors.New("incompatible protocol version of client and server") | ||
} | ||
if version.Version != wss.CoreVersion { | ||
log.WithFields(log.Fields{ | ||
"client wssocks version": wss.CoreVersion, | ||
"server wssocks version": version.Version, | ||
}).Warning("different versions of client and server wssocks.") | ||
} | ||
return nil | ||
} |
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,4 +1,4 @@ | ||
package vpn_plugin | ||
package vpn | ||
|
||
import ( | ||
"bufio" | ||
|
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,4 +1,4 @@ | ||
package vpn_plugin | ||
package vpn | ||
|
||
import ( | ||
"regexp" | ||
|
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,4 +1,4 @@ | ||
package vpn_plugin | ||
package vpn | ||
|
||
import ( | ||
"crypto/aes" | ||
|
2 changes: 1 addition & 1 deletion
2
vpn_plugin/host_encrypt_test.go → plugins/vpn/host_encrypt_test.go
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,4 +1,4 @@ | ||
package vpn_plugin | ||
package vpn | ||
|
||
import ( | ||
"encoding/hex" | ||
|
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,4 +1,4 @@ | ||
package vpn_plugin | ||
package vpn | ||
|
||
import ( | ||
"bufio" | ||
|
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,4 +1,4 @@ | ||
package vpn_plugin | ||
package vpn | ||
|
||
import ( | ||
"net/url" | ||
|
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