Only attempt to use systemd on linux

Remove plan9 builds
This commit is contained in:
Frank Denis 2018-01-24 15:14:48 +01:00
parent d208d38f3f
commit 94f9c14ad7
4 changed files with 42 additions and 25 deletions

View File

@ -14,9 +14,6 @@ script:
- curl -L https://download.dnscrypt.info/tools/upx-linux > upx
- chmod +x upx
- go clean
- env GOOS=plan9 go build -ldflags="-s -w" && ./upx --lzma --best dnscrypt-proxy
- go clean
- env GOOS=solaris go build -ldflags="-s -w" && ./upx --lzma --best dnscrypt-proxy

View File

@ -10,8 +10,6 @@ import (
"sync"
"time"
"github.com/coreos/go-systemd/activation"
"github.com/coreos/go-systemd/daemon"
"github.com/jedisct1/dlog"
"github.com/kardianos/service"
"golang.org/x/crypto/curve25519"
@ -166,13 +164,13 @@ func (proxy *Proxy) StartProxy() {
dlog.Fatal(err)
}
}
if err := proxy.systemDListeners(); err != nil {
if err := proxy.SystemDListeners(); err != nil {
dlog.Fatal(err)
}
liveServers, err := proxy.serversInfo.refresh(proxy)
if liveServers > 0 {
dlog.Noticef("dnscrypt-proxy is ready - live servers: %d", liveServers)
daemon.SdNotify(false, "READY=1")
SystemDNotify()
} else if err != nil {
dlog.Error(err)
dlog.Notice("dnscrypt-proxy is waiting for at least one server to be reachable")
@ -265,24 +263,6 @@ func (proxy *Proxy) tcpListenerFromAddr(listenAddr *net.TCPAddr) error {
return nil
}
func (proxy *Proxy) systemDListeners() error {
listeners, err := activation.Listeners(true)
if err != nil && len(listeners) > 0 {
for i, listener := range listeners {
dlog.Noticef("Wiring systemd TCP socket #%d", i)
proxy.tcpListener(listener.(*net.TCPListener))
}
}
packetConns, err := activation.PacketConns(true)
if err != nil && len(packetConns) > 0 {
for i, packetConn := range packetConns {
dlog.Noticef("Wiring systemd UDP socket #%d", i)
proxy.udpListener(packetConn.(*net.UDPConn))
}
}
return nil
}
func (proxy *Proxy) exchangeWithUDPServer(serverInfo *ServerInfo, encryptedQuery []byte, clientNonce []byte) ([]byte, error) {
pc, err := net.DialUDP("udp", nil, serverInfo.UDPAddr)
if err != nil {

View File

@ -0,0 +1,9 @@
// +build !linux
package main
func (proxy *Proxy) SystemDListeners() error {
return nil
}
func SystemDNotify() {}

View File

@ -0,0 +1,31 @@
package main
import (
"net"
"github.com/coreos/go-systemd/activation"
"github.com/coreos/go-systemd/daemon"
"github.com/jedisct1/dlog"
)
func (proxy *Proxy) SystemDListeners() error {
listeners, err := activation.Listeners(true)
if err != nil && len(listeners) > 0 {
for i, listener := range listeners {
dlog.Noticef("Wiring systemd TCP socket #%d", i)
proxy.tcpListener(listener.(*net.TCPListener))
}
}
packetConns, err := activation.PacketConns(true)
if err != nil && len(packetConns) > 0 {
for i, packetConn := range packetConns {
dlog.Noticef("Wiring systemd UDP socket #%d", i)
proxy.udpListener(packetConn.(*net.UDPConn))
}
}
return nil
}
func SystemDNotify() {
daemon.SdNotify(false, "READY=1")
}