fixing
This commit is contained in:
@@ -5,12 +5,25 @@ import (
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"packets/internal"
|
||||
"path/filepath"
|
||||
"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 {
|
||||
|
||||
_, err := os.Stat(fmt.Sprintf("/var/cache/packets/%s", filename))
|
||||
_, err := os.Stat(filepath.Join(cfg.Config.DefaultCacheDir))
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
} else {
|
||||
@@ -21,9 +34,10 @@ func CheckDownloaded(filename string) bool {
|
||||
|
||||
func main() {
|
||||
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)
|
||||
}
|
||||
toml.Decode(filepath.Join(internal.PacketsPackageDir(), "config.toml"), &cfg)
|
||||
|
||||
addr := net.UDPAddr{IP: net.IPv4zero, Port: 1333}
|
||||
conn, err := net.ListenUDP("udp", &addr)
|
||||
|
||||
Reference in New Issue
Block a user