activate http proxy
This commit is contained in:
@ -77,7 +77,6 @@ it's own application. The package will need to give the application
|
||||
CAP\_NET\_BIND\_SERVICE or something. This might work:
|
||||
|
||||
sudo setcap cap_net_bind_service=epi ./bin/samcatd
|
||||
sudo setcap cap_net_bind_service=epi ./bin/samcatd-web
|
||||
|
||||
But I need to learn more about capabilities before I make that part of the
|
||||
thing.
|
||||
|
@ -10,26 +10,25 @@ func NewSAMHTTPClientFromConf(config *Conf) (*i2phttpproxy.SAMHTTPProxy, error)
|
||||
if config != nil {
|
||||
return i2phttpproxy.NewHttpProxy(
|
||||
i2phttpproxy.SetKeysPath(config.KeyFilePath),
|
||||
/*i2phttpproxy.SetHost(*samHostString),
|
||||
i2phttpproxy.SetPort(*samPortString),
|
||||
i2phttpproxy.SetProxyAddr(ln.Addr().String()),
|
||||
i2phttpproxy.SetControlAddr(cln.Addr().String()),
|
||||
i2phttpproxy.SetDebug(*debugConnection),
|
||||
i2phttpproxy.SetInLength(uint(*inboundTunnelLength)),
|
||||
i2phttpproxy.SetOutLength(uint(*outboundTunnelLength)),
|
||||
i2phttpproxy.SetInQuantity(uint(*inboundTunnels)),
|
||||
i2phttpproxy.SetOutQuantity(uint(*outboundTunnels)),
|
||||
i2phttpproxy.SetInBackups(uint(*inboundBackups)),
|
||||
i2phttpproxy.SetOutBackups(uint(*outboundBackups)),
|
||||
i2phttpproxy.SetInVariance(*inboundVariance),
|
||||
i2phttpproxy.SetOutVariance(*outboundVariance),
|
||||
i2phttpproxy.SetUnpublished(*dontPublishLease),
|
||||
i2phttpproxy.SetReduceIdle(*reduceIdle),
|
||||
i2phttpproxy.SetCompression(*useCompression),
|
||||
i2phttpproxy.SetReduceIdleTime(uint(*reduceIdleTime)),
|
||||
i2phttpproxy.SetReduceIdleQuantity(uint(*reduceIdleQuantity)),
|
||||
i2phttpproxy.SetCloseIdle(*closeIdle),
|
||||
i2phttpproxy.SetCloseIdleTime(uint(*closeIdleTime)),*/
|
||||
i2phttpproxy.SetHost(config.SamHost),
|
||||
i2phttpproxy.SetPort(config.SamPort),
|
||||
i2phttpproxy.SetProxyAddr(config.TargetHost+":"+config.TargetPort),
|
||||
//i2phttpproxy.SetControlAddr(),
|
||||
i2phttpproxy.SetInLength(uint(config.InLength)),
|
||||
i2phttpproxy.SetOutLength(uint(config.OutLength)),
|
||||
i2phttpproxy.SetInQuantity(uint(config.InQuantity)),
|
||||
i2phttpproxy.SetOutQuantity(uint(config.OutQuantity)),
|
||||
i2phttpproxy.SetInBackups(uint(config.InBackupQuantity)),
|
||||
i2phttpproxy.SetOutBackups(uint(config.OutBackupQuantity)),
|
||||
i2phttpproxy.SetInVariance(config.InVariance),
|
||||
i2phttpproxy.SetOutVariance(config.OutVariance),
|
||||
i2phttpproxy.SetUnpublished(config.Client),
|
||||
i2phttpproxy.SetReduceIdle(config.ReduceIdle),
|
||||
i2phttpproxy.SetCompression(config.UseCompression),
|
||||
i2phttpproxy.SetReduceIdleTime(uint(config.ReduceIdleTime)),
|
||||
i2phttpproxy.SetReduceIdleQuantity(uint(config.ReduceIdleQuantity)),
|
||||
i2phttpproxy.SetCloseIdle(config.CloseIdle),
|
||||
i2phttpproxy.SetCloseIdleTime(uint(config.CloseIdleTime)),
|
||||
)
|
||||
}
|
||||
return nil, nil
|
||||
|
@ -17,7 +17,7 @@ outbound.allowZeroHop = false
|
||||
i2cp.encryptLeaseSet = false
|
||||
gzip = true
|
||||
i2cp.reduceOnIdle = true
|
||||
i2cp.reduceIdleTime = 3000000
|
||||
i2cp.reduceIdleTime = 300000
|
||||
i2cp.reduceQuantity = 2
|
||||
i2cp.enableWhiteList = false
|
||||
i2cp.enableBlackList = false
|
||||
@ -29,7 +29,7 @@ i2cp.enableBlackList = false
|
||||
#port = 8081
|
||||
#inbound.length = 3
|
||||
#outbound.length = 3
|
||||
#keys = forwarder
|
||||
#keys = tcpserver
|
||||
|
||||
#[sam-forwarder-tcp-client]
|
||||
#type = client
|
||||
@ -38,15 +38,15 @@ i2cp.enableBlackList = false
|
||||
#inbound.length = 3
|
||||
#outbound.length = 3
|
||||
#destination = i2p-projekt.i2p
|
||||
#keys = forwarder-two
|
||||
#keys = tcpclient
|
||||
|
||||
[sam-forwarder-udp-server]
|
||||
type = udpserver
|
||||
host = 127.0.0.1
|
||||
port = 8084
|
||||
inbound.length = 6
|
||||
outbound.length = 3
|
||||
keys = forwarder-four
|
||||
#[sam-forwarder-udp-server]
|
||||
#type = udpserver
|
||||
#host = 127.0.0.1
|
||||
#port = 8084
|
||||
#inbound.length = 6
|
||||
#outbound.length = 3
|
||||
#keys = udpserver
|
||||
|
||||
#[sam-forwarder-udp-client]
|
||||
#type = udpclient
|
||||
@ -54,16 +54,24 @@ keys = forwarder-four
|
||||
#port = 8083
|
||||
#inbound.length = 3
|
||||
#outbound.length = 3
|
||||
#destination = i2p-projekt.i2p
|
||||
#keys = forwarder-three
|
||||
#destination = pointmeatatrealudpserveritwillbreakwithoutone.b32.i2p
|
||||
#keys = udpclient
|
||||
|
||||
[sam-forwarder-tcp-http-server]
|
||||
type = http
|
||||
#[sam-forwarder-tcp-http-server]
|
||||
#type = http
|
||||
#host = 127.0.0.1
|
||||
#port = 8085
|
||||
#inbound.length = 3
|
||||
#outbound.length = 3
|
||||
#keys = httpserver
|
||||
|
||||
[sam-forwarder-tcp-http-client]
|
||||
type = httpclient
|
||||
host = 127.0.0.1
|
||||
port = 8085
|
||||
port = 8087
|
||||
inbound.length = 3
|
||||
outbound.length = 3
|
||||
keys = forwarder-five
|
||||
keys = proxy
|
||||
|
||||
#[sam-forwarder-vpn-server]
|
||||
#type = udpserver
|
||||
|
@ -75,7 +75,7 @@ func (m *TunnelHandlerMux) Home(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte(fmt.Sprintf("Welcome %s! you are serving %d tunnels.\n", m.user, len(m.tunnels))))
|
||||
fmt.Fprintf(w, "</h1>\n")
|
||||
fmt.Fprintf(w, " <div id=\"toggleall\" class=\"global control prop\">\n")
|
||||
fmt.Fprintf(w, " <a href=\"#\" onclick=\"toggle_visibility_class('%s');\">Show/Hide %s</a>", "prop", "all")
|
||||
fmt.Fprintf(w, " <a href=\"#\" onclick=\"toggle_visibility_class('%s');\">Show/Hide %s</a>\n", "prop", "all")
|
||||
fmt.Fprintf(w, " </div>\n")
|
||||
for _, tunnel := range m.Tunnels() {
|
||||
tunnel.ServeHTTP(w, r2)
|
||||
|
@ -89,6 +89,10 @@ function toggle_visibility_class(id) {
|
||||
for (let c of clist) {
|
||||
c.style.display = 'block';
|
||||
}
|
||||
var slist = document.getElementsByClassName("status")
|
||||
for (let s of slist) {
|
||||
s.style.display = 'block';
|
||||
}
|
||||
}
|
||||
toggle_visibility_class("prop")
|
||||
`
|
||||
|
@ -42,8 +42,8 @@ func (t *TunnelHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
t.Printdivf(t.SAMTunnel.ID(), "TunName", t.SAMTunnel.ID(), rw, req)
|
||||
fmt.Fprintf(rw, " <span id=\"toggle%s\" class=\"control\">\n", t.SAMTunnel.ID())
|
||||
fmt.Fprintf(rw, " <a href=\"#\" onclick=\"toggle_visibility_class('%s');\"> Show/Hide %s</a>", t.SAMTunnel.ID(), t.SAMTunnel.ID())
|
||||
fmt.Fprintf(rw, " <a href=\"/%s/color\">Tunnel page</a>", t.SAMTunnel.ID())
|
||||
fmt.Fprintf(rw, " <a href=\"#\" onclick=\"toggle_visibility_class('%s');\"> Show/Hide %s</a>\n", t.SAMTunnel.ID(), t.SAMTunnel.ID())
|
||||
fmt.Fprintf(rw, " <a href=\"/%s/color\">Tunnel page</a>\n", t.SAMTunnel.ID())
|
||||
fmt.Fprintf(rw, " </span>\n")
|
||||
for key, value := range t.SAMTunnel.Props() {
|
||||
if key != "TunName" {
|
||||
@ -59,6 +59,7 @@ func (t *TunnelHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||
fmt.Fprintf(rw, " <a href=\"/%s/start\">.[START]</a>", t.SAMTunnel.ID())
|
||||
fmt.Fprintf(rw, " <a href=\"/%s/stop\">.[STOP].</a>", t.SAMTunnel.ID())
|
||||
fmt.Fprintf(rw, " <a href=\"/%s/restart\">[RESTART].</a><br>", t.SAMTunnel.ID())
|
||||
fmt.Fprintf(rw, " <div id=\"%s.status\" class=\"%s status\">.[STATUS].</div>", t.SAMTunnel.ID(), t.SAMTunnel.ID())
|
||||
if strings.HasSuffix(req.URL.Path, "color") {
|
||||
fmt.Fprintf(rw, " </div>\n\n")
|
||||
}
|
||||
|
@ -115,6 +115,13 @@ func NewSAMManagerFromOptions(opts ...func(*SAMManager) error) (*SAMManager, err
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "httpclient":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunconf.NewSAMHTTPClientFromConfig(s.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
log.Println("found http under", label)
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "server":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunconf.NewSAMForwarderFromConfig(s.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
log.Println("found server under", label)
|
||||
@ -167,6 +174,13 @@ func NewSAMManagerFromOptions(opts ...func(*SAMManager) error) (*SAMManager, err
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "httpclient":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunconf.NewSAMForwarderFromConfig(s.FilePath, s.SamHost, s.SamPort)); e == nil {
|
||||
log.Println("found default http")
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "server":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunconf.NewSAMForwarderFromConfig(s.FilePath, s.SamHost, s.SamPort)); e == nil {
|
||||
log.Println("found default server")
|
||||
|
Reference in New Issue
Block a user