最近Jetbrians系列IDE更新至2017.3版本,激活检测机制也变成了动态封禁域名,导致大部分域名激活被屏蔽了,所以找了下资料,根据ilanyu的代码,改了下地址,实现了本地反向代理激活服务器。
具体Go代码如下test.go:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
package main import ( "flag" "log" "net/http" "net/http/httputil" "net/url" ) type handle struct { reverseProxy string } func (this *handle) ServeHTTP(w http.ResponseWriter, r *http.Request) { remote, err := url.Parse(this.reverseProxy) if err != nil { log.Fatalln(err) } proxy := httputil.NewSingleHostReverseProxy(remote) r.Host = remote.Host proxy.ServeHTTP(w, r) log.Println(r.RemoteAddr + " " + r.Method + " " + r.URL.String() + " " + r.Proto + " " + r.UserAgent()) } func main() { bind := flag.String("l", "0.0.0.0:8888", "listen on ip:port") remote := flag.String("r", "http://idea.imsxm.com:80", "reverse proxy addr") flag.Parse() log.Printf("Listening on %s, forwarding to %s", *bind, *remote) h := &handle{reverseProxy: *remote} err := http.ListenAndServe(*bind, h) if err != nil { log.Fatalln("ListenAndServe: ", err) } } |
使用方法: mac系统,直接 go run test.go
1
2
3
4
5
6
7
直接打开或者命令行加参数
可选参数:
-l string
listen on ip:port (default "0.0.0.0:8888")
-r string
reverse proxy addr (default "http://idea.imsxm.com:80")
暂时只编译了windows X64平台,并且UPX打包,激活时输入http://localhost:8888就行。
下载地址:点我下载V1.0
也可使用nginx/apache等web服务器 反向代理,nginx配置如下,将location段放在server段中
1 2 3 4 5 6 7 |
location /rpc { proxy_pass http://idea.imsxm.com/rpc; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } |
转载:http://www.imsxm.com/2017/12/go-active-proxy-tool.html
原文地址:https://www.cnblogs.com/shengulong/p/8312968.html