diff --git a/Dockerfile b/Dockerfile index c502d63..1acc55f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ WORKDIR /src COPY go.mod go.sum ./ RUN go mod download COPY . . -RUN CGO_ENABLED=0 go build -ldflags "-X main.Version=${CHECKER_VERSION}" -o /checker-ns-restrictions . +RUN CGO_ENABLED=0 go build -tags standalone -ldflags "-X main.Version=${CHECKER_VERSION}" -o /checker-ns-restrictions . FROM scratch COPY --from=builder /checker-ns-restrictions /checker-ns-restrictions diff --git a/Makefile b/Makefile index 7324d03..2c0872e 100644 --- a/Makefile +++ b/Makefile @@ -6,12 +6,12 @@ CHECKER_SOURCES := main.go $(wildcard checker/*.go) GO_LDFLAGS := -X main.Version=$(CHECKER_VERSION) -.PHONY: all plugin docker clean +.PHONY: all plugin docker test clean all: $(CHECKER_NAME) $(CHECKER_NAME): $(CHECKER_SOURCES) - go build -ldflags "$(GO_LDFLAGS)" -o $@ . + go build -tags standalone -ldflags "$(GO_LDFLAGS)" -o $@ . plugin: $(CHECKER_NAME).so @@ -21,5 +21,8 @@ $(CHECKER_NAME).so: $(CHECKER_SOURCES) $(wildcard plugin/*.go) docker: docker build --build-arg CHECKER_VERSION=$(CHECKER_VERSION) -t $(CHECKER_IMAGE) . +test: + go test -tags standalone ./... + clean: rm -f $(CHECKER_NAME) $(CHECKER_NAME).so diff --git a/checker/collect.go b/checker/collect.go index 7ab9990..0a81567 100644 --- a/checker/collect.go +++ b/checker/collect.go @@ -63,7 +63,7 @@ func (p *nsProvider) Collect(ctx context.Context, opts sdk.CheckerOptions) (any, // serviceFromOptions extracts a *serviceMessage from the options. It accepts // either a direct value (in-process plugin path) or a JSON-decoded -// map[string]any (HTTP path) — both are normalized via a JSON round-trip. +// map[string]any (HTTP path), both are normalized via a JSON round-trip. func serviceFromOptions(opts sdk.CheckerOptions) (*serviceMessage, error) { v, ok := opts["service"] if !ok { diff --git a/checker/interactive.go b/checker/interactive.go index d7de7c8..3506d22 100644 --- a/checker/interactive.go +++ b/checker/interactive.go @@ -1,3 +1,5 @@ +//go:build standalone + package checker import ( @@ -11,7 +13,7 @@ import ( "github.com/miekg/dns" ) -// RenderForm implements sdk.CheckerInteractive. It lists the minimal human +// RenderForm implements server.Interactive. It lists the minimal human // inputs needed to bootstrap a check when this checker runs standalone // (outside of a happyDomain host). func (p *nsProvider) RenderForm() []sdk.CheckerOptionField { @@ -27,9 +29,9 @@ func (p *nsProvider) RenderForm() []sdk.CheckerOptionField { } } -// ParseForm implements sdk.CheckerInteractive. It resolves the NS records +// ParseForm implements server.Interactive. It resolves the NS records // for the requested domain via DNS and assembles the CheckerOptions that -// Collect expects — replacing the AutoFill work that happyDomain would +// Collect expects, replacing the AutoFill work that happyDomain would // otherwise perform. func (p *nsProvider) ParseForm(r *http.Request) (sdk.CheckerOptions, error) { domain := strings.TrimSpace(r.FormValue("domain")) diff --git a/go.mod b/go.mod index 906fafe..63525b0 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module git.happydns.org/checker-ns-restrictions go 1.25.0 require ( - git.happydns.org/checker-sdk-go v1.2.0 + git.happydns.org/checker-sdk-go v1.3.0 github.com/miekg/dns v1.1.72 ) diff --git a/go.sum b/go.sum index d64ca7c..092728a 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -git.happydns.org/checker-sdk-go v1.2.0 h1:v4MpKAz0W3PwP+bxx3pya8w893sVH5xTD1of1cc0TV8= -git.happydns.org/checker-sdk-go v1.2.0/go.mod h1:aNAcfYFfbhvH9kJhE0Njp5GX0dQbxdRB0rJ0KvSC5nI= +git.happydns.org/checker-sdk-go v1.3.0 h1:FG2kIhlJCzI0m35EhxSgn4UWc9M4ha6aZTeoChu4l7A= +git.happydns.org/checker-sdk-go v1.3.0/go.mod h1:aNAcfYFfbhvH9kJhE0Njp5GX0dQbxdRB0rJ0KvSC5nI= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/miekg/dns v1.1.72 h1:vhmr+TF2A3tuoGNkLDFK9zi36F2LS+hKTRW0Uf8kbzI= diff --git a/main.go b/main.go index 2ea54aa..1b3419f 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,7 @@ import ( "log" nsr "git.happydns.org/checker-ns-restrictions/checker" - sdk "git.happydns.org/checker-sdk-go/checker" + "git.happydns.org/checker-sdk-go/checker/server" ) // Version is the standalone binary's version. It defaults to "custom-build" @@ -23,8 +23,8 @@ func main() { // CheckerDefinition.Version. nsr.Version = Version - server := sdk.NewServer(nsr.Provider()) - if err := server.ListenAndServe(*listenAddr); err != nil { + srv := server.New(nsr.Provider()) + if err := srv.ListenAndServe(*listenAddr); err != nil { log.Fatalf("server error: %v", err) } }