Ejemplo n.º 1
0
func main() {
	logger := log.New(os.Stderr, "http2socks: ", log.LstdFlags|log.Lshortfile)

	flag.Parse()

	prxy := goproxy.NewProxyHttpServer()
	prxy.Logger = logger
	prxy.Verbose = *verbose

	dialer, err := proxy.SOCKS5("tcp", *socksAddr, nil, proxy.Direct)
	if err != nil {
		log.Fatal(err)
	}

	prxy.Tr = &http.Transport{Dial: dialer.Dial}

	logger.Fatal(http.ListenAndServe(*listenAddr, prxy))
}
Ejemplo n.º 2
0
func Start(op Options) {
	options = op

	proxy = goproxy.NewProxyHttpServer()
	proxy.Verbose = false

	proxy.OnRequest().DoFunc(onRequestHandler)
	proxy.OnResponse().DoFunc(onResponseHandler)

	cacher.SetExportFolder(options.ExportFolder)

	if !options.Record {
		cacher.Load("stub.json")
		logger.Info("In the middle has been started in REPLAY mode. Press ^C to terminate In the middle.")
	} else {
		logger.Info("In the middle has been started in RECORD mode. Press ^C to terminate In the middle.")
	}

	logger.Info("Current settings")
	logger.Info(options)

	http.ListenAndServe(options.Ip+":"+options.Port, proxy)
}