fix unix socket listener
This commit is contained in:
parent
2337551fb3
commit
54c93a178a
31
README.md
31
README.md
|
@ -34,19 +34,26 @@ location '/wp-login.php' {
|
|||
If the configuration file is missing, the default settings will automatically drop itself in the current working directory as `config.toml`.
|
||||
|
||||
```
|
||||
title = "HellPot"
|
||||
|
||||
[logger]
|
||||
debug = false
|
||||
log_directory = "./logs/"
|
||||
[diception]
|
||||
server_name = "nginx"
|
||||
|
||||
[http]
|
||||
bind_addr = "127.0.0.1"
|
||||
bind_port = "8080"
|
||||
# paths to be added to robots.txt that we will respond to
|
||||
paths = [
|
||||
"wp-login.php",
|
||||
"wp-login",
|
||||
]
|
||||
bind_addr = "127.0.0.1"
|
||||
bind_port = "8080"
|
||||
paths = ["wp-login.php","wp-login"]
|
||||
unix_socket = "/var/run/hellpot"
|
||||
use_unix_socket = false
|
||||
|
||||
[logger]
|
||||
debug = true
|
||||
directory = "/home/kayos/.config/HellPot/logs/"
|
||||
nocolor = false
|
||||
use_date_filename = true
|
||||
|
||||
[performance]
|
||||
# max_workers is only valid if restrict_concurrency is true
|
||||
restrict_concurrency = false
|
||||
max_workers = 256
|
||||
|
||||
```
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ var (
|
|||
f *os.File
|
||||
err error
|
||||
|
||||
NoColorForce = false
|
||||
NoColor bool
|
||||
customconfig = false
|
||||
home string
|
||||
|
@ -159,10 +160,10 @@ func setDefaults() {
|
|||
"use_date_filename": true,
|
||||
}
|
||||
Opt["http"] = map[string]interface{}{
|
||||
"use_unix_socket": false,
|
||||
"unix_socket": "/var/run/hellpot",
|
||||
"bind_addr": "127.0.0.1",
|
||||
"bind_port": "8080",
|
||||
"use_unix_socket": false,
|
||||
"unix_socket_path": "/var/run/hellpot",
|
||||
"bind_addr": "127.0.0.1",
|
||||
"bind_port": "8080",
|
||||
"paths": []string{
|
||||
"wp-login.php",
|
||||
"wp-login",
|
||||
|
@ -215,12 +216,17 @@ func argParse() {
|
|||
for i, arg := range os.Args {
|
||||
switch arg {
|
||||
case "-h":
|
||||
println("HellPot: use -c <file.toml> to specify config file.")
|
||||
println("HellPot Usage")
|
||||
println("-c <config.toml> - Specify config file")
|
||||
println("--nocolor - disable color and banner ")
|
||||
println("--banner - show banner + version and exit")
|
||||
os.Exit(0)
|
||||
case "--config":
|
||||
fallthrough
|
||||
case "--nocolor":
|
||||
NoColorForce = true
|
||||
case "--banner":
|
||||
BannerOnly = true
|
||||
case "--config":
|
||||
fallthrough
|
||||
case "-c":
|
||||
if len(os.Args) <= i-1 {
|
||||
panic("syntax error! expected file after -c")
|
||||
|
@ -246,7 +252,6 @@ func associate() {
|
|||
Opt = newOpt
|
||||
Debug = snek.GetBool("logger.debug")
|
||||
logDir = snek.GetString("logger.directory")
|
||||
NoColor = snek.GetBool("logger.nocolor")
|
||||
BindAddr = snek.GetString("http.bind_addr")
|
||||
BindPort = snek.GetString("http.bind_port")
|
||||
Paths = snek.GetStringSlice("http.paths")
|
||||
|
@ -254,7 +259,10 @@ func associate() {
|
|||
FakeServerName = snek.GetString("diception.server_name")
|
||||
RestrictConcurrency = snek.GetBool("performance.restrict_concurrency")
|
||||
MaxWorkers = snek.GetInt("performance.max_workers")
|
||||
|
||||
NoColor = snek.GetBool("logger.nocolor")
|
||||
if NoColorForce {
|
||||
NoColor = true
|
||||
}
|
||||
if UseUnixSocket {
|
||||
UnixSocketPath = snek.GetString("http.unix_socket_path")
|
||||
}
|
||||
|
|
|
@ -65,9 +65,7 @@ func listenOnUnixSocket(addr string, r *router.Router) error {
|
|||
unixAddr, err = net.ResolveUnixAddr("unix", addr)
|
||||
if err == nil {
|
||||
// Always unlink sockets before listening on them
|
||||
if err2 := syscall.Unlink(addr); err2 != nil {
|
||||
panic(err2)
|
||||
}
|
||||
syscall.Unlink(addr)
|
||||
unixListener, err = net.ListenUnix("unix", unixAddr)
|
||||
if err == nil {
|
||||
err = fasthttp.Serve(unixListener, r.Handler)
|
||||
|
|
Loading…
Reference in New Issue