Null-DRM-Official/apps/pkg/proxy/embed.go
404errordeveloper da8e1123ec
All checks were successful
release / build-and-upload (push) Successful in 7m5s
Streamd v0.2.0: rename, modules panel, stable/beta channels
- 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
2026-10-10 15:58:26 +02:00

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
}