Mobile bindings

This commit is contained in:
eyedeekay
2025-02-07 17:01:34 -05:00
parent 1441220c7c
commit a0d148ad79
11 changed files with 50 additions and 21 deletions

View File

@ -10,4 +10,22 @@ doc: checklist
find lib cmd -type d -exec $(HERE)/doc.sh {} \; find lib cmd -type d -exec $(HERE)/doc.sh {} \;
checklist: checklist:
find . -name '*.go' -exec grep --color -C 1 -Hn 'panic("unimplemented")' {} \; find . -name '*.go' -exec grep --color -C 1 -Hn 'panic("unimplemented")' {} \;
mobile:
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
bindSetupMobile: mobile
go get -u golang.org/x/mobile/bind
mobileLibs:
gomobile bind -target=android ./lib/tcp/client
gomobile bind -target=android ./lib/tcp/server
gomobile bind -target=android ./lib/udp/client
gomobile bind -target=android ./lib/udp/server
gomobile bind -target=android ./lib/irc/client
gomobile bind -target=android ./lib/irc/server
gomobile bind -target=android ./lib/http/client
gomobile bind -target=android ./lib/http/server
gomobile bind -target=android ./lib/socks/client

View File

@ -37,5 +37,5 @@ type I2PTunnel interface {
// Get the tunnel's error message // Get the tunnel's error message
Error() error Error() error
// Get the tunnel's local host:port // Get the tunnel's local host:port
LocalAddress() (string, string, error) LocalAddress() (string, error)
} }

View File

@ -23,6 +23,7 @@ Key features:
**/ **/
import ( import (
"net"
"strconv" "strconv"
httpinspector "github.com/go-i2p/go-connfilter/http" httpinspector "github.com/go-i2p/go-connfilter/http"
@ -67,8 +68,9 @@ func (h *HTTPClient) Error() error {
} }
// Get the tunnel's local host:port // Get the tunnel's local host:port
func (h *HTTPClient) LocalAddress() (string, string, error) { func (h *HTTPClient) LocalAddress() (string, error) {
return h.TunnelConfig.Interface, strconv.Itoa(h.TunnelConfig.Port), nil addr := net.JoinHostPort(h.TunnelConfig.Interface, strconv.Itoa(h.TunnelConfig.Port))
return addr, nil
} }
// Get the tunnel's name // Get the tunnel's name

View File

@ -76,8 +76,9 @@ func (h *HTTPServer) Error() error {
} }
// Get the tunnel's local host:port // Get the tunnel's local host:port
func (h *HTTPServer) LocalAddress() (string, string, error) { func (h *HTTPServer) LocalAddress() (string, error) {
return h.TunnelConfig.Interface, strconv.Itoa(h.TunnelConfig.Port), nil addr := net.JoinHostPort(h.TunnelConfig.Interface, strconv.Itoa(h.TunnelConfig.Port))
return addr, nil
} }
// Get the tunnel's name // Get the tunnel's name

View File

@ -13,6 +13,7 @@ The IRC Client implements a SOCKS-compatible proxy that enables local IRC client
**/ **/
import ( import (
"net"
"strconv" "strconv"
ircinspector "github.com/go-i2p/go-connfilter/irc" ircinspector "github.com/go-i2p/go-connfilter/irc"
@ -60,8 +61,9 @@ func (i *IRCClient) Error() error {
} }
// Get the tunnel's local host:port // Get the tunnel's local host:port
func (i *IRCClient) LocalAddress() (string, string, error) { func (i *IRCClient) LocalAddress() (string, error) {
return i.TunnelConfig.Interface, strconv.Itoa(i.TunnelConfig.Port), nil addr := net.JoinHostPort(i.TunnelConfig.Interface, strconv.Itoa(i.TunnelConfig.Port))
return addr, nil
} }
// Get the tunnel's name // Get the tunnel's name

View File

@ -66,8 +66,9 @@ func (i *IRCServer) Error() error {
} }
// Get the tunnel's local host:port // Get the tunnel's local host:port
func (i *IRCServer) LocalAddress() (string, string, error) { func (i *IRCServer) LocalAddress() (string, error) {
return i.TunnelConfig.Interface, strconv.Itoa(i.TunnelConfig.Port), nil addr := net.JoinHostPort(i.TunnelConfig.Interface, strconv.Itoa(i.TunnelConfig.Port))
return addr, nil
} }
// Get the tunnel's name // Get the tunnel's name

View File

@ -92,8 +92,9 @@ func (s *SOCKS) Error() error {
} }
// Get the tunnel's local host:port // Get the tunnel's local host:port
func (s *SOCKS) LocalAddress() (string, string, error) { func (s *SOCKS) LocalAddress() (string, error) {
return s.TunnelConfig.Interface, strconv.Itoa(s.TunnelConfig.Port), nil addr := net.JoinHostPort(s.TunnelConfig.Interface, strconv.Itoa(s.TunnelConfig.Port))
return addr, nil
} }
// Get the tunnel's name // Get the tunnel's name

View File

@ -69,8 +69,9 @@ func (t *TCPClient) Error() error {
} }
// Get the tunnel's local host:port // Get the tunnel's local host:port
func (t *TCPClient) LocalAddress() (string, string, error) { func (t *TCPClient) LocalAddress() (string, error) {
return t.TunnelConfig.Interface, strconv.Itoa(t.TunnelConfig.Port), nil addr := net.JoinHostPort(t.TunnelConfig.Interface, strconv.Itoa(t.TunnelConfig.Port))
return addr, nil
} }
// Get the tunnel's name // Get the tunnel's name

View File

@ -16,6 +16,7 @@ When an I2P peer connects to the tunnel's destination, the traffic flows:
import ( import (
"context" "context"
"net" "net"
"strconv"
"github.com/go-i2p/go-forward/config" "github.com/go-i2p/go-forward/config"
"github.com/go-i2p/go-forward/stream" "github.com/go-i2p/go-forward/stream"
@ -63,9 +64,9 @@ func (t *TCPServer) Error() error {
} }
// Get the tunnel's local host:port // Get the tunnel's local host:port
func (t *TCPServer) LocalAddress() (string, string, error) { func (t *TCPServer) LocalAddress() (string, error) {
addr := t.Addr.String() addr := net.JoinHostPort(t.TunnelConfig.Interface, strconv.Itoa(t.TunnelConfig.Port))
return net.SplitHostPort(addr) return addr, nil
} }
// Get the tunnel's name // Get the tunnel's name

View File

@ -71,8 +71,9 @@ func (u *UDPClient) Error() error {
} }
// Get the tunnel's local host:port // Get the tunnel's local host:port
func (u *UDPClient) LocalAddress() (string, string, error) { func (u *UDPClient) LocalAddress() (string, error) {
return u.TunnelConfig.Interface, strconv.Itoa(u.TunnelConfig.Port), nil addr := net.JoinHostPort(u.TunnelConfig.Interface, strconv.Itoa(u.TunnelConfig.Port))
return addr, nil
} }
// Get the tunnel's name // Get the tunnel's name

View File

@ -71,8 +71,9 @@ func (u *UDPServer) Error() error {
} }
// Get the tunnel's local host:port // Get the tunnel's local host:port
func (u *UDPServer) LocalAddress() (string, string, error) { func (u *UDPServer) LocalAddress() (string, error) {
return u.TunnelConfig.Interface, strconv.Itoa(u.TunnelConfig.Port), nil addr := net.JoinHostPort(u.TunnelConfig.Interface, strconv.Itoa(u.TunnelConfig.Port))
return addr, nil
} }
// Get the tunnel's name // Get the tunnel's name