Giter Club home page Giter Club logo

frp-modify's Introduction

frp-Modify

使用说明

  • cmd/frpc/sub/root.go#getFileContent()函数中,按需修改 FRPC 配置和key(默认testkey
func getFileContent(ip string, port string) {
	key := "testkey"
	ip = str2xor(ip, key)
	port = str2xor(port, key)

	var configContent string = `[common]
        server_addr = ` + ip + `
        server_port = ` + port + `
	tls_enable = true 
	[plugin_socks]
	type = tcp
	remote_port = 7788
	plugin = socks5
	#plugin_user = ""
	#plugin_passwd = ""
	`
	fileContent = configContent
}
  • 确保安装 Go-1.16+ 和 GCC 环境,然后运行package.sh进行交叉编译
$ go env -w GOPROXY=https://goproxy.cn,direct  # 设置代理
$ ./package.sh
  • FRPS正常运行,FRPC则需要传入异或后的字符串。可通过xor.py脚本进行异或,异或后的字符串可能存在特殊字符\,因此建议使用双引号包裹
$ ./frpc -t <IP> -p <端口>
$ ./frpc -t "E\AZZSAZTBEET" -p "CUCD"  # 192.168.111.1:7000

钉钉提醒

  • 需要在client/control.go#HandleNewProxyResp()函数中配置钉钉机器人AccessTokenSecret,然后在前面的配置部分添加相关plugin_userplugin_passwd即可
func (ctl *Control) HandleNewProxyResp(inMsg *msg.NewProxyResp) {
    // ...

	if err != nil {
		xl.Warn("[%s] start error: %v", inMsg.ProxyName, err)
	} else {
		// 配置钉钉机器人
		dingAccessToken := ""
		dingSecret := ""
        
        // ...
	}

    // ...
}

域前置

  • 修改依赖包 go/pkg/mod/golang.org/x/[email protected]/websocket/client.go#NewConfig() 方法,添加回源 Host
func NewConfig(server, origin string) (config *Config, err error) {
	config = new(Config)
	config.Version = ProtocolVersionHybi13
	config.Location, err = url.ParseRequestURI(server)
	if err != nil {
		return
	}
	config.Origin, err = url.ParseRequestURI(origin)
	if err != nil {
		return
	}
	config.Header = http.Header(make(map[string][]string))
+	config.Header.Set("Host", "test.baidu.local")
	return
}
  • 然后修改 go/pkg/mod/golang.org/x/[email protected]/websocket/hybi.go#hybiClientHandshake() 方法
func hybiClientHandshake(config *Config, br *bufio.Reader, bw *bufio.Writer) (err error) {
	bw.WriteString("GET " + config.Location.RequestURI() + " HTTP/1.1\r\n")

	// According to RFC 6874, an HTTP client, proxy, or other
	// intermediary must remove any IPv6 zone identifier attached
	// to an outgoing URI.

+	// FRP Websocket Host
+	host := config.Location.Host
+	if tmpHost := config.Header.Get("Host"); tmpHost != "" {
+		host = tmpHost
+	}
+	bw.WriteString("Host: " + removeZone(host) + "\r\n")
+	// bw.WriteString("Host: " + removeZone(config.Location.Host) + "\r\n")
 
    // ...
}
  • 最后在cmd/frpc/sub/root.go#getFileContent()中配置开启 Websocket 协议
protocol = websocket

参考文章

frp-modify's People

Contributors

m1r0ku avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.