2021-12-20 14:53:42 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
2021-12-22 07:01:30 -05:00
|
|
|
"pndpd/pndp"
|
2021-12-20 14:53:42 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2021-12-22 06:04:00 -05:00
|
|
|
fmt.Println("PNDPD Version 0.4 by Kioubit")
|
2021-12-20 16:46:26 -05:00
|
|
|
|
2021-12-22 06:04:00 -05:00
|
|
|
if len(os.Args) <= 2 {
|
|
|
|
printUsage()
|
|
|
|
return
|
2021-12-20 14:53:42 -05:00
|
|
|
}
|
2021-12-22 06:04:00 -05:00
|
|
|
|
|
|
|
switch os.Args[1] {
|
|
|
|
case "respond":
|
2021-12-21 06:42:30 -05:00
|
|
|
if len(os.Args) == 4 {
|
2021-12-22 07:01:30 -05:00
|
|
|
pndp.SimpleRespond(os.Args[2], pndp.ParseFilter(os.Args[3]))
|
2021-12-21 06:42:30 -05:00
|
|
|
} else {
|
2021-12-22 07:01:30 -05:00
|
|
|
pndp.SimpleRespond(os.Args[2], nil)
|
2021-12-21 06:42:30 -05:00
|
|
|
}
|
2021-12-22 06:04:00 -05:00
|
|
|
case "proxy":
|
2021-12-22 07:01:30 -05:00
|
|
|
pndp.Proxy(os.Args[2], os.Args[3])
|
2021-12-22 06:04:00 -05:00
|
|
|
case "readconfig":
|
2021-12-21 06:42:30 -05:00
|
|
|
readConfig(os.Args[2])
|
2021-12-22 06:04:00 -05:00
|
|
|
default:
|
|
|
|
printUsage()
|
|
|
|
return
|
2021-12-21 06:00:28 -05:00
|
|
|
}
|
2021-12-22 07:01:30 -05:00
|
|
|
pndp.WaitForSignal()
|
2021-12-22 06:04:00 -05:00
|
|
|
}
|
2021-12-20 16:46:26 -05:00
|
|
|
|
2021-12-22 06:04:00 -05:00
|
|
|
func printUsage() {
|
|
|
|
fmt.Println("Specify command")
|
|
|
|
fmt.Println("Usage: pndpd readconfig <path to file>")
|
|
|
|
fmt.Println("Usage: pndpd respond <interface> <optional whitelist of CIDRs separated with a semicolon>")
|
|
|
|
fmt.Println("Usage: pndpd proxy <interface1> <interface2>")
|
2021-12-20 14:53:42 -05:00
|
|
|
}
|