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