heiher / hev-socks5-tunnel

A high-performance tun2socks for Linux/Android/FreeBSD/macOS/iOS/WSL2 (IPv4/IPv6/TCP/UDP)
MIT License
636 stars 130 forks source link

Pass config as string instead of file #95

Closed SaeedDev94 closed 4 months ago

SaeedDev94 commented 4 months ago

Is it possible to pass config as string in yaml format instead of a file?

#!/bin/bash

TUN_SETUP="$(realpath $0) routing"

main() {
  CONF="
tunnel:
  mtu: 8500
  post-up-script: '$TUN_SETUP'
"

  hev-socks5-tunnel "$CONF"
}

routing() {
  # handle routing
}

case $1 in
  "routing")
    routing;;
  *)
    main;;
esac

The separate file isn't easy to maintain ... I mean if someone like me wants to handle all jobs in a one script file that's not possible for now

heiher commented 4 months ago

How about creating a temp file for config?

echo "yaml ..." > /tmp/hs5t.yml
hev-socks5-tunnel /tmp/hs5t.yml