mode

package
v0.0.1-alpha9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeTCPHash

func ComputeTCPHash(password, salt string) string

ComputeTCPHash returns md5( md5(password) + "." + salt ) used by GnuDIP TCP clients.

func GetQueryParam

func GetQueryParam(q map[string][]string, names ...string) string

func ParseReqc

func ParseReqc(raw string) (int, error)

Exported helpers for reuse and testing.

func ResolveRequestIP

func ResolveRequestIP(reqc int, providedIP, remote string) (string, error)

func SetDebugMode

func SetDebugMode(enabled bool)

SetDebugMode toggles debug behaviours across modes.

func VerifyPassword

func VerifyPassword(storedPassword, inputPassword string) bool

Types

type DynMode

type DynMode struct {
	// contains filtered or unexported fields
}

DynMode holds shared DynDNS-like behaviour (DynDNS, DtDNS, EasyDNS, Oray).

func NewDynMode

func NewDynMode(numeric bool, debug func(format string, args ...interface{})) *DynMode

func (*DynMode) Prepare

func (m *DynMode) Prepare(r *http.Request) (*Request, Outcome)

Prepare extracts credentials, domain and IP info from the HTTP request.

func (*DynMode) Process

func (m *DynMode) Process(req *Request) Outcome

Process authenticates the user and executes the provider update.

func (*DynMode) Respond

func (m *DynMode) Respond(w http.ResponseWriter, req *Request, outcome Outcome)

Respond writes protocol-specific responses.

type EasyDNSMode

type EasyDNSMode struct {
	*DynMode
}

EasyDNSMode is intentionally kept as a distinct type even though it embeds DynMode. This preserves a clear separation between the EasyDNS protocol surface and the generic DynDNS behavior, and allows EasyDNS-specific behavior or response mapping to evolve independently of DynMode.

func (*EasyDNSMode) Respond

func (m *EasyDNSMode) Respond(w http.ResponseWriter, req *Request, outcome Outcome)

Respond writes EasyDNS dynamic DNS result codes as plain-text responses. It implements the EasyDNS API contract by mapping internal outcomes to EasyDNS result strings (each terminated with a newline):

  • OutcomeSuccess -> "NOERROR\n"
  • OutcomeAuthFailure -> "NOACCESS\n"
  • OutcomeInvalidDomain -> "ILLEGAL INPUT\n"
  • OutcomeSystemError -> "NOSERVICE\n"
  • any other outcome -> "NOSERVICE\n"

For protocol details, see the EasyDNS dynamic DNS API documentation. The "NOERROR\n" response is required by many easyDNS clients (e.g., inadyn).

type GnuHTTPMode

type GnuHTTPMode struct {
	// contains filtered or unexported fields
}

GnuHTTPMode implements the two-step GnuDIP HTTP challenge flow. Step 1: client requests without pass/sign -> server returns meta tags with retc/time/sign/addr. Step 2: client requests with pass/sign (md5(user:time:secret)) -> server validates and updates.

func (*GnuHTTPMode) Prepare

func (m *GnuHTTPMode) Prepare(r *http.Request) (*Request, Outcome)

func (*GnuHTTPMode) Process

func (m *GnuHTTPMode) Process(req *Request) Outcome

func (*GnuHTTPMode) Respond

func (m *GnuHTTPMode) Respond(w http.ResponseWriter, req *Request, outcome Outcome)

type GnuTCPMode

type GnuTCPMode struct {
	// contains filtered or unexported fields
}

GnuTCPMode handles GnuDIP TCP protocol.

func NewGnuTCPMode

func NewGnuTCPMode(debug func(format string, args ...interface{})) *GnuTCPMode

func (*GnuTCPMode) Handle

func (m *GnuTCPMode) Handle(conn net.Conn)

type Mode

type Mode interface {
	Prepare(*http.Request) (*Request, Outcome)
	Process(*Request) Outcome
	Respond(http.ResponseWriter, *Request, Outcome)
}

Mode defines a protocol handler that can prepare, process, and respond to a DDNS HTTP request.

func NewEasyDNSMode

func NewEasyDNSMode(debug func(format string, args ...interface{})) Mode

func NewGnuHTTPMode

func NewGnuHTTPMode(debug func(format string, args ...interface{})) Mode

type Outcome

type Outcome int

Outcome represents the result of a mode processing step.

const (
	OutcomeSuccess Outcome = iota
	OutcomeAuthFailure
	OutcomeInvalidDomain
	OutcomeSystemError
)

type Request

type Request struct {
	Username   string
	Password   string
	Domain     string
	IP         string
	Reqc       int
	RemoteAddr string
	Time       string
	// Salt is the cryptographic salt for GnuDIP authentication.
	Salt string
	// Sign is the MD5 signature for challenge-response authentication.
	Sign string
}

Request holds normalized DDNS parameters.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL