mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-03-04 10:24:40 +01:00
Accept data from systemd sockets at the same time as everything else
This commit is contained in:
parent
4029d3d4f3
commit
52f87aee8e
4 changed files with 8 additions and 17 deletions
|
@ -557,16 +557,15 @@ func ConfigLoad(proxy *Proxy, flags *ConfigFlags) error {
|
||||||
for _, listenAddrStr := range proxy.localDoHListenAddresses {
|
for _, listenAddrStr := range proxy.localDoHListenAddresses {
|
||||||
proxy.addLocalDoHListener(listenAddrStr)
|
proxy.addLocalDoHListener(listenAddrStr)
|
||||||
}
|
}
|
||||||
|
if err := proxy.addSystemDListeners(); err != nil {
|
||||||
|
dlog.Fatal(err)
|
||||||
|
}
|
||||||
_ = pidfile.Write()
|
_ = pidfile.Write()
|
||||||
// if 'userName' is set and we are the parent process drop privilege and exit
|
// if 'userName' is set and we are the parent process drop privilege and exit
|
||||||
if len(proxy.userName) > 0 && !proxy.child {
|
if len(proxy.userName) > 0 && !proxy.child {
|
||||||
proxy.dropPrivilege(proxy.userName, FileDescriptors)
|
proxy.dropPrivilege(proxy.userName, FileDescriptors)
|
||||||
dlog.Fatal("Dropping privileges is not supporting on this operating system. Unset `user_name` in the configuration file.")
|
dlog.Fatal("Dropping privileges is not supporting on this operating system. Unset `user_name` in the configuration file.")
|
||||||
}
|
}
|
||||||
if err := proxy.SystemDListeners(); err != nil {
|
|
||||||
dlog.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !config.OfflineMode {
|
if !config.OfflineMode {
|
||||||
if err := config.loadSources(proxy); err != nil {
|
if err := config.loadSources(proxy); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
func (proxy *Proxy) SystemDListeners() error {
|
func (proxy *Proxy) addSystemDListeners() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
func (proxy *Proxy) SystemDListeners() error {
|
func (proxy *Proxy) addSystemDListeners() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,14 +3,13 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/coreos/go-systemd/activation"
|
"github.com/coreos/go-systemd/activation"
|
||||||
"github.com/jedisct1/dlog"
|
"github.com/jedisct1/dlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (proxy *Proxy) SystemDListeners() error {
|
func (proxy *Proxy) addSystemDListeners() error {
|
||||||
files := activation.Files(true)
|
files := activation.Files(true)
|
||||||
|
|
||||||
if len(files) > 0 {
|
if len(files) > 0 {
|
||||||
|
@ -21,20 +20,13 @@ func (proxy *Proxy) SystemDListeners() error {
|
||||||
}
|
}
|
||||||
for i, file := range files {
|
for i, file := range files {
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
ok := false
|
|
||||||
if listener, err := net.FileListener(file); err == nil {
|
if listener, err := net.FileListener(file); err == nil {
|
||||||
dlog.Noticef("Wiring systemd TCP socket #%d, %s, %s", i, file.Name(), listener.Addr())
|
dlog.Noticef("Wiring systemd TCP socket #%d, %s, %s", i, file.Name(), listener.Addr())
|
||||||
ok = true
|
proxy.tcpListener = append(proxy.tcpListener, listener.(*net.TCPListener))
|
||||||
go proxy.tcpListener(listener.(*net.TCPListener))
|
|
||||||
} else if pc, err := net.FilePacketConn(file); err == nil {
|
} else if pc, err := net.FilePacketConn(file); err == nil {
|
||||||
dlog.Noticef("Wiring systemd UDP socket #%d, %s, %s", i, file.Name(), pc.LocalAddr())
|
dlog.Noticef("Wiring systemd UDP socket #%d, %s, %s", i, file.Name(), pc.LocalAddr())
|
||||||
ok = true
|
proxy.udpListener = append(proxy.udpListener, listener.(*net.UDPConn))
|
||||||
go proxy.udpListener(pc.(*net.UDPConn))
|
|
||||||
}
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("Could not wire systemd socket #%d, %s", i, file.Name())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue