Udp socket giving the right http port
This commit is contained in:
@@ -14,8 +14,8 @@ import (
|
|||||||
|
|
||||||
type ConfigTOML struct {
|
type ConfigTOML struct {
|
||||||
Config struct {
|
Config struct {
|
||||||
DefaultHttpPort int `toml:"httpPort"`
|
HttpPort int `toml:"httpPort"`
|
||||||
DefaultCacheDir string `toml:"cacheDir"`
|
CacheDir string `toml:"cacheDir"`
|
||||||
} `toml:"Config"`
|
} `toml:"Config"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ var cfg ConfigTOML
|
|||||||
|
|
||||||
func CheckDownloaded(filename string) bool {
|
func CheckDownloaded(filename string) bool {
|
||||||
|
|
||||||
_, err := os.Stat(filepath.Join(cfg.Config.DefaultCacheDir))
|
_, err := os.Stat(filepath.Join(cfg.Config.CacheDir))
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
@@ -58,7 +58,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
filename := strings.TrimPrefix(msg, "Q:")
|
filename := strings.TrimPrefix(msg, "Q:")
|
||||||
if CheckDownloaded(filename) {
|
if CheckDownloaded(filename) {
|
||||||
reply := fmt.Sprintf("H:%s:%d", filename, 9123)
|
reply := fmt.Sprintf("H:%s:%d", filename, cfg.Config.HttpPort)
|
||||||
conn.WriteToUDP([]byte(reply), remote)
|
conn.WriteToUDP([]byte(reply), remote)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user