goofy little web browser
This commit is contained in:
BIN
browser/browser
Executable file
BIN
browser/browser
Executable file
Binary file not shown.
194
browser/main.go
Normal file
194
browser/main.go
Normal file
@ -0,0 +1,194 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
import (
|
||||
"crawshaw.io/littleboss"
|
||||
"github.com/danfragoso/thdwb/ketchup"
|
||||
"github.com/danfragoso/thdwb/mustard"
|
||||
"github.com/danfragoso/thdwb/sauce"
|
||||
. "github.com/eyedeekay/httptunnel"
|
||||
)
|
||||
|
||||
var (
|
||||
tunnelName = flag.String("service-name", "sam-http-proxy", "Name of the service(can be anything)")
|
||||
samHostString = flag.String("bridge-host", "127.0.0.1", "host: of the SAM bridge")
|
||||
samPortString = flag.String("bridge-port", "7656", ":port of the SAM bridge")
|
||||
watchProfiles = flag.String("watch-profiles", "~/.mozilla/.firefox.profile.i2p.default/user.js,~/.mozilla/.firefox.profile.i2p.debug/user.js", "Monitor and control these Firefox profiles")
|
||||
destfile = flag.String("dest-file", "invalid.tunkey", "Use a long-term destination key")
|
||||
debugConnection = flag.Bool("conn-debug", true, "Print connection debug info")
|
||||
inboundTunnelLength = flag.Int("in-tun-length", 2, "Tunnel Length(default 3)")
|
||||
outboundTunnelLength = flag.Int("out-tun-length", 2, "Tunnel Length(default 3)")
|
||||
inboundTunnels = flag.Int("in-tunnels", 2, "Inbound Tunnel Count(default 2)")
|
||||
outboundTunnels = flag.Int("out-tunnels", 2, "Outbound Tunnel Count(default 2)")
|
||||
inboundBackups = flag.Int("in-backups", 1, "Inbound Backup Count(default 1)")
|
||||
outboundBackups = flag.Int("out-backups", 1, "Inbound Backup Count(default 1)")
|
||||
inboundVariance = flag.Int("in-variance", 0, "Inbound Backup Count(default 0)")
|
||||
outboundVariance = flag.Int("out-variance", 0, "Inbound Backup Count(default 0)")
|
||||
dontPublishLease = flag.Bool("no-publish", true, "Don't publish the leaseset(Client mode)")
|
||||
encryptLease = flag.Bool("encrypt-lease", false, "Encrypt the leaseset(default false, inert)")
|
||||
reduceIdle = flag.Bool("reduce-idle", false, "Reduce tunnels on extended idle time")
|
||||
closeIdle = flag.Bool("close-idle", false, "Close tunnels on extended idle time")
|
||||
closeIdleTime = flag.Int("close-idle-time", 3000000, "Reduce tunnels after time(Ms)")
|
||||
useCompression = flag.Bool("use-compression", true, "Enable gzip compression")
|
||||
reduceIdleTime = flag.Int("reduce-idle-time", 2000000, "Reduce tunnels after time(Ms)")
|
||||
reduceIdleQuantity = flag.Int("reduce-idle-tunnels", 1, "Reduce tunnels to this level")
|
||||
runArguments = flag.String("run-arguments", "", "Pass arguments to run-command")
|
||||
suppressLifetime = flag.Bool("suppress-lifetime-output", false, "Suppress \"Tunnel lifetime\" output")
|
||||
runQuiet = flag.Bool("run-quiet", true, "Suppress all non-command output")
|
||||
outproxy = flag.String("outproxy-addr", "false.i2p", "Use this address as an outproxy, either a base32 address or a local HTTP proxy")
|
||||
socks = flag.Bool("outproxy-socks", true, "Use a SOCKS outproxy")
|
||||
)
|
||||
|
||||
var addr string
|
||||
|
||||
func main() {
|
||||
lb := littleboss.New(*tunnelName)
|
||||
proxyaddr := "127.0.0.1:7950"
|
||||
controladdr := "127.0.0.1:7951"
|
||||
for _, flag := range os.Args {
|
||||
if flag == "-run-command" {
|
||||
proxyaddr = "127.0.0.1:0"
|
||||
controladdr = "127.0.0.1:0"
|
||||
}
|
||||
}
|
||||
ln := lb.Listener("proxy-addr", "tcp", proxyaddr, "The address of the proxy")
|
||||
cln := lb.Listener("control-addr", "tcp", controladdr, "The address of the controller")
|
||||
lb.Run(func(ctx context.Context) {
|
||||
proxyMain(ctx, ln.Listener(), cln.Listener())
|
||||
})
|
||||
}
|
||||
|
||||
func proxyMain(ctx context.Context, ln net.Listener, cln net.Listener) {
|
||||
flag.Parse()
|
||||
/*if *runCommand != "" {
|
||||
*suppressLifetime = true
|
||||
*runQuiet = true
|
||||
*debugConnection = false
|
||||
}*/
|
||||
profiles := strings.Split(*watchProfiles, ",")
|
||||
|
||||
srv := &http.Server{
|
||||
ReadTimeout: 600 * time.Second,
|
||||
WriteTimeout: 10 * time.Second,
|
||||
Addr: ln.Addr().String(),
|
||||
}
|
||||
var err error
|
||||
srv.Handler, err = NewHttpProxy(
|
||||
SetHost(*samHostString),
|
||||
SetPort(*samPortString),
|
||||
SetProxyAddr(ln.Addr().String()),
|
||||
SetControlAddr(cln.Addr().String()),
|
||||
SetOutProxy(*outproxy),
|
||||
SetOutProxySocks(*socks),
|
||||
SetDebug(*debugConnection),
|
||||
SetInLength(uint(*inboundTunnelLength)),
|
||||
SetOutLength(uint(*outboundTunnelLength)),
|
||||
SetInQuantity(uint(*inboundTunnels)),
|
||||
SetOutQuantity(uint(*outboundTunnels)),
|
||||
SetInBackups(uint(*inboundBackups)),
|
||||
SetOutBackups(uint(*outboundBackups)),
|
||||
SetInVariance(*inboundVariance),
|
||||
SetOutVariance(*outboundVariance),
|
||||
SetUnpublished(*dontPublishLease),
|
||||
SetReduceIdle(*reduceIdle),
|
||||
SetCompression(*useCompression),
|
||||
SetReduceIdleTime(uint(*reduceIdleTime)),
|
||||
SetReduceIdleQuantity(uint(*reduceIdleQuantity)),
|
||||
SetCloseIdle(*closeIdle),
|
||||
SetCloseIdleTime(uint(*closeIdleTime)),
|
||||
SetKeysPath(*destfile),
|
||||
)
|
||||
Quiet = *runQuiet
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
ctrlsrv := &http.Server{
|
||||
ReadHeaderTimeout: 600 * time.Second,
|
||||
WriteTimeout: 600 * time.Second,
|
||||
Addr: cln.Addr().String(),
|
||||
}
|
||||
ctrlsrv.Handler, err = NewSAMHTTPController(profiles, srv)
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
|
||||
go func() {
|
||||
for sig := range c {
|
||||
if sig == os.Interrupt {
|
||||
srv.Handler.(*SAMHTTPProxy).Close()
|
||||
srv.Shutdown(ctx)
|
||||
ctrlsrv.Shutdown(ctx)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
log.Println("Starting control server on", cln.Addr())
|
||||
if err := ctrlsrv.Serve(cln); err != nil {
|
||||
if err == http.ErrServerClosed {
|
||||
return
|
||||
}
|
||||
log.Fatal("Serve:", err)
|
||||
}
|
||||
log.Println("Stopping control server on", cln.Addr())
|
||||
}()
|
||||
|
||||
go func() {
|
||||
log.Println("Starting proxy server on", ln.Addr())
|
||||
if err := srv.Serve(ln); err != nil {
|
||||
if err == http.ErrServerClosed {
|
||||
return
|
||||
}
|
||||
log.Fatal("Serve:", err)
|
||||
}
|
||||
log.Println("Stopping proxy server on", ln.Addr())
|
||||
}()
|
||||
|
||||
go counter()
|
||||
|
||||
os.Setenv("http_proxy", "http://"+ln.Addr().String())
|
||||
os.Setenv("https_proxy", "http://"+ln.Addr().String())
|
||||
os.Setenv("ftp_proxy", "http://"+ln.Addr().String())
|
||||
os.Setenv("all_proxy", "http://"+ln.Addr().String())
|
||||
os.Setenv("HTTP_PROXY", "http://"+ln.Addr().String())
|
||||
os.Setenv("HTTPS_PROXY", "http://"+ln.Addr().String())
|
||||
os.Setenv("FTP_PROXY", "http://"+ln.Addr().String())
|
||||
os.Setenv("ALL_PROXY", "http://"+ln.Addr().String())
|
||||
|
||||
log.Println("Waiting a few seconds for the proxy to start")
|
||||
time.Sleep(time.Duration(10 * time.Second))
|
||||
|
||||
//log.Println("Launching ", *runCommand, "with proxy http://"+ln.Addr().String())
|
||||
url := flag.Arg(0)
|
||||
resource := sauce.GetResource(url)
|
||||
htmlString := string(resource.Body)
|
||||
parsedDocument := ketchup.ParseDocument(htmlString)
|
||||
|
||||
mustard.RenderDocument(parsedDocument, url)
|
||||
return
|
||||
|
||||
<-ctx.Done()
|
||||
}
|
||||
|
||||
func counter() {
|
||||
var x int
|
||||
for {
|
||||
if !*suppressLifetime {
|
||||
log.Println("Identity is", x, "minute(s) old")
|
||||
time.Sleep(1 * time.Minute)
|
||||
x++
|
||||
}
|
||||
}
|
||||
}
|
5
go.mod
5
go.mod
@ -3,11 +3,16 @@ module github.com/eyedeekay/httptunnel
|
||||
go 1.12
|
||||
|
||||
require (
|
||||
crawshaw.io/littleboss v0.0.0-20190317185602-8957d0aedcce
|
||||
github.com/danfragoso/thdwb v0.0.0-20191106005607-18cfeb88e782
|
||||
github.com/eyedeekay/goSam v0.1.1-0.20190814204230-d4c9b8c57dd6
|
||||
github.com/eyedeekay/sam-forwarder v0.0.0-20190908210105-71ca8cd65fda
|
||||
github.com/eyedeekay/sam3 v0.0.0-20190730185140-f8d54526ea25
|
||||
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 // indirect
|
||||
github.com/go-gl/glfw v0.0.0-20191125211704-12ad95a8df72 // indirect
|
||||
github.com/mwitkow/go-http-dialer v0.0.0-20161116154839-378f744fb2b8
|
||||
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
|
||||
github.com/tfriedel6/canvas v0.9.2 // indirect
|
||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
|
||||
)
|
||||
|
BIN
roboto.ttf
Normal file
BIN
roboto.ttf
Normal file
Binary file not shown.
Reference in New Issue
Block a user