fixing
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"packets/internal"
|
"packets/internal"
|
||||||
|
|
||||||
@@ -22,10 +23,10 @@ func main() {
|
|||||||
|
|
||||||
internal.PacketsPackageDir()
|
internal.PacketsPackageDir()
|
||||||
var cfg ConfigTOML
|
var cfg ConfigTOML
|
||||||
toml.Decode("opt/packets/packets/config.toml", &cfg)
|
toml.Decode(filepath.Join(internal.PacketsPackageDir(), "config.toml"), &cfg)
|
||||||
|
|
||||||
pid := os.Getpid()
|
pid := os.Getpid()
|
||||||
if err := os.WriteFile("./http.pid", []byte(fmt.Sprint(pid)), 0644); err != nil {
|
if err := os.WriteFile(filepath.Join(internal.PacketsPackageDir(), "http.pid"), []byte(fmt.Sprint(pid)), 0644); err != nil {
|
||||||
fmt.Println("error saving subprocess pid", err)
|
fmt.Println("error saving subprocess pid", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,25 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"packets/internal"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/BurntSushi/toml"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ConfigTOML struct {
|
||||||
|
Config struct {
|
||||||
|
DefaultHttpPort int `toml:"httpPort"`
|
||||||
|
DefaultCacheDir string `toml:"cacheDir"`
|
||||||
|
} `toml:"Config"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var cfg ConfigTOML
|
||||||
|
|
||||||
func CheckDownloaded(filename string) bool {
|
func CheckDownloaded(filename string) bool {
|
||||||
|
|
||||||
_, err := os.Stat(fmt.Sprintf("/var/cache/packets/%s", filename))
|
_, err := os.Stat(filepath.Join(cfg.Config.DefaultCacheDir))
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
@@ -21,9 +34,10 @@ func CheckDownloaded(filename string) bool {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
pid := os.Getpid()
|
pid := os.Getpid()
|
||||||
if err := os.WriteFile("/opt/packets/packets/udp.pid", []byte(fmt.Sprint(pid)), 0644); err != nil {
|
if err := os.WriteFile(filepath.Join(internal.PacketsPackageDir(), "udp.pid"), []byte(fmt.Sprint(pid)), 0644); err != nil {
|
||||||
fmt.Println("error saving subprocess pid", err)
|
fmt.Println("error saving subprocess pid", err)
|
||||||
}
|
}
|
||||||
|
toml.Decode(filepath.Join(internal.PacketsPackageDir(), "config.toml"), &cfg)
|
||||||
|
|
||||||
addr := net.UDPAddr{IP: net.IPv4zero, Port: 1333}
|
addr := net.UDPAddr{IP: net.IPv4zero, Port: 1333}
|
||||||
conn, err := net.ListenUDP("udp", &addr)
|
conn, err := net.ListenUDP("udp", &addr)
|
||||||
|
|||||||
Reference in New Issue
Block a user