【声明】 转载 自 文章
最近Jetbrians系列IDE更新至2017.3版本,激活检测机制也变成了动态封禁域名,导致大部分域名激活被屏蔽了,所以找了下资料,根据ilanyu的代码,改了下地址,实现了本地反向代理激活服务器。
具体Go代码如下:
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)
}
}
使用方法:
可选参数:
-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