1.挺好用的socks5库

github.com/armon/go-socks5

2.示例代码

// Create a SOCKS5 server
conf := &socks5.Config{}
server, err := socks5.New(conf)
if err != nil {
panic(err)
} // Create SOCKS5 proxy on localhost port 8000
if err := server.ListenAndServe("tcp", "127.0.0.1:8000"); err != nil {
panic(err)
}

很简洁,当然正式用不能这么用,默认是没有认证的,也就是说所有人都能连你服务器。。

加认证也很简单

cred := StaticCredentials{
"foo": "bar",
} cator := UserPassAuthenticator{Credentials: cred} s, _ := New(&Config{AuthMethods: []Authenticator{cator}})

下面详细看一下这个认证

Config结构体:

// Config is used to setup and configure a Server
type Config struct {
// AuthMethods can be provided to implement custom authentication
// By default, "auth-less" mode is enabled.
// For password-based auth use UserPassAuthenticator.
AuthMethods []Authenticator // If provided, username/password authentication is enabled,
// by appending a UserPassAuthenticator to AuthMethods. If not provided,
// and AUthMethods is nil, then "auth-less" mode is enabled.
Credentials CredentialStore // Resolver can be provided to do custom name resolution.
// Defaults to DNSResolver if not provided.
Resolver NameResolver // Rules is provided to enable custom logic around permitting
// various commands. If not provided, PermitAll is used.
Rules RuleSet // Rewriter can be used to transparently rewrite addresses.
// This is invoked before the RuleSet is invoked.
// Defaults to NoRewrite.
Rewriter AddressRewriter // BindIP is used for bind or udp associate
BindIP net.IP // Logger can be used to provide a custom log target.
// Defaults to stdout.
Logger *log.Logger // Optional function for dialing out
Dial func(ctx context.Context, network, addr string) (net.Conn, error)
}

config结构体里面要传入AuthMethods

AuthMethods是一个Authenticator切片,Authenticator是个interface,

type Authenticator interface {
Authenticate(reader io.Reader, writer io.Writer) (*AuthContext, error)
GetCode() uint8
}

UserPassAuthenticator 实现了Authenticator

// UserPassAuthenticator is used to handle username/password based
// authentication
type UserPassAuthenticator struct {
Credentials CredentialStore
} func (a UserPassAuthenticator) GetCode() uint8 {
return UserPassAuth
}

最后转化为填充一个UserPassAuthenticator的Credentials ,

而Credentials 是一个map[string]string

type StaticCredentials map[string]string

最后要把Config里面的logger 字段给填了(这里略),就差不多能用了。

3. 适用场景

适用移动网络访问github慢的场景。不知道为啥移动上github总是很慢。在公司电信网络就很快,之前家里用联通的时候也没这个现象,我上github你限制我干吗。。用此socks配合浏览器插件foxyProxy绕过移动网络直连github效果明显。注意foxyProxy里面设置Patterns ,不然什么请求到服务器上绕一圈可是有点过了。。

挺好用的socks5库go-socks5的更多相关文章

  1. requests库使用socks5代理

    备查: #!usr/bin/env python # coding=utf-8 import requests proxies = {'https': 'https://127.0.0.1:1080' ...

  2. socks5服务器编写经验总结

    一.Socks5服务器实现设计 本Socks5服务器是之前做的一个项目中的一个小部分东西,该项目是一个可以实现多级转发代理网络通讯的项目,能够隐藏网络数据包的源IP地址和端口,能够为上网的用户提供安全 ...

  3. HTTP协议和SOCKS5协议

    HTTP协议和SOCKS5协议 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 我们平时上网的时候基本上是离不开浏览器的,尤其是搜索资料的时候,那么这个浏览器是如何工作的呢?用的又是 ...

  4. 自己动手开发Socks5代理服务器

    一.Socks5协议简介 socks5是基于传输层的协议,客户端和服务器经过两次握手协商之后服务端为客户端建立一条到目标服务器的通道,在传输层转发TCP/UDP流量. 关于socks5协议规范,到处都 ...

  5. SOCKS5的出现缓解了各种具体协议需要专门设计代理协议的困难局面

    socks5_百度百科 https://baike.baidu.com/item/socks5/8915011?fr=aladdin 如果您的机器具有一个合法的 Internet IP 地址, 或者您 ...

  6. 转-linux下配置socks5代理

    简介: 在Linux下有各种各样的代理程序可用,象最常用的Squid,是http/https代理,也能代理ftp请求,但它实际上 是个HTTP代理程序,不是ftp代理,但它能处理ftp代理请求,就象浏 ...

  7. 爬虫学习--Requests库详解 Day2

    什么是Requests Requests是用python语言编写,基于urllib,采用Apache2 licensed开源协议的HTTP库,它比urllib更加方便,可以节约我们大量的工作,完全满足 ...

  8. 所有selenium相关的库

    通过爬虫 获取 官方文档库 如果想获取 相应的库 修改对应配置即可 代码如下 from urllib.parse import urljoin import requests from lxml im ...

  9. 一起学习Boost标准库--Boost.texical_cast&format库

    今天接续介绍有关字符串表示相关的两个boost库: lexical_cast 将数值转换成字符串 format 字符串输出格式化 首先,介绍下lexical_cast ,闻其名,知其意.类似C中的at ...

随机推荐

  1. 数据挖掘入门系列教程(十点五)之DNN介绍及公式推导

    深度神经网络(DNN,Deep Neural Networks)简介 首先让我们先回想起在之前博客(数据挖掘入门系列教程(七点五)之神经网络介绍)中介绍的神经网络:为了解决M-P模型中无法处理XOR等 ...

  2. 使用 Junit + Mockito 实践单元测试

    一.前言 相信做过开发的同学,都多多少少写过下面的代码,很长一段时间我一直以为这就是单元测试... @SpringBootTest @RunWith(SpringRunner.class) publi ...

  3. 2019-2020-1 20199310《Linux内核原理与分析》第九周作业

    1.问题描述 在前面的文章中,学习了译链接的过程和ELF可执行文件格式,对Linux内核装载和启动一个可执行程序,本次内容围绕对进程调度的时机和进程切换进行,分析进程的调度时机,调度策略和算法,并跟踪 ...

  4. Linux系统管理第一二三四章 系统管理 目录和文件管理 安装及管理程序 账号管理

    命令 功能 序号 第一章   cd 切换目录 1 stat 查看文件状态信息 2 cp 复制   -f -i -p -r 3 du 统计磁盘的大小 4 find 精细查找文件和目录 5 help 帮助 ...

  5. NumPy学习指南(第2版)

    第一章 NumPy快速入门 首先,我们将介绍如何在不同的操作系统中安装NumPy和相关软件,并给出使用NumPy的简单示例代码. 然后,我们将简单介绍IPython(一种交互式shell工具). 如前 ...

  6. 移动端上传图片(引入exif-js,图片被压缩为base64)

    <template> <div class="vue-box"> <img :src="imgUrl" alt="&qu ...

  7. 一个简单的wed服务器SHTTPD(6)———— SHTTPD错误处理的实现

    //start from the very beginning,and to create greatness //@author: Chuangwei Lin //@E-mail:979951191 ...

  8. uiautomatorviewer 出现安卓8.0级以上无法打开的解决方法

    一..本人在使用Android自带的uiautomatorviewer工具来进行app元素定位时,出现了Android 9.0打开不了.出现了如下图错误提示: 经过网上的查阅,总结了几个解决的方法. ...

  9. S - Making the Grade POJ - 3666 结论 将严格递减转化成非严格的

    S - Making the Grade POJ - 3666 这个题目要求把一个给定的序列变成递增或者递减序列的最小代价. 这个是一个dp,对于这个dp的定义我觉得不是很好想,如果第一次碰到的话. ...

  10. mui日期设置与时钟样式时间设置

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...