All checks were successful
release / build-and-upload (push) Successful in 7m5s
- Rename product/host binary to streamd (drm compat copy still shipped) - Go module path streamd; STREAMD_* env aliases; agent UA streamd-agent - Panel Modules store + agent pull sync (modstore / modsync) - Rolling stable + beta download tags; README/docs channel curl blocks - Release notes in docs/releases/v0.2.0.md attached by Forgejo Actions
58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package proxy
|
|
|
|
import (
|
|
_ "embed"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"streamd/adb"
|
|
"streamd/repo"
|
|
)
|
|
|
|
//go:embed embedded/tproxy_iptables.sh
|
|
var embeddedTProxyScript []byte
|
|
|
|
// ensureTProxyScript pushes the iptables helper to the phone.
|
|
// Prefers the source-tree copy; falls back to the copy embedded in streamd
|
|
// so a portable release zip does not need apps/proxy/device/.
|
|
func ensureTProxyScript(c *adb.Client) error {
|
|
candidates := []string{
|
|
filepath.Join(repo.Root(), "apps", "proxy", "device", "tproxy_iptables.sh"),
|
|
}
|
|
if exe, err := os.Executable(); err == nil {
|
|
dir := filepath.Dir(exe)
|
|
candidates = append(candidates,
|
|
filepath.Join(dir, "tproxy_iptables.sh"),
|
|
filepath.Join(dir, "apps", "proxy", "device", "tproxy_iptables.sh"),
|
|
)
|
|
}
|
|
var local string
|
|
for _, p := range candidates {
|
|
if st, err := os.Stat(p); err == nil && !st.IsDir() {
|
|
local = p
|
|
break
|
|
}
|
|
}
|
|
tmp := filepath.Join(os.TempDir(), "tproxy_iptables.sh")
|
|
if local != "" {
|
|
data, err := os.ReadFile(local)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := os.WriteFile(tmp, data, 0o755); err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
if err := os.WriteFile(tmp, embeddedTProxyScript, 0o755); err != nil {
|
|
return err
|
|
}
|
|
fmt.Println("[*] Using embedded tproxy_iptables.sh")
|
|
}
|
|
defer os.Remove(tmp)
|
|
if err := c.Push(tmp, RemoteTProxyScript); err != nil {
|
|
return err
|
|
}
|
|
_, _ = c.Shell("chmod", "755", RemoteTProxyScript)
|
|
return nil
|
|
}
|