zns

package module
v0.0.0-...-5e64bca Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 17 Imported by: 0

README

ZNS - Simple DoH server in Go

Install

go install github.com/taoso/zns/cmd/zns@latest

Run

zns -free -tls-hosts zns.example.org -root /var/www/html

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FreeTicketRepo

type FreeTicketRepo struct{}

func (FreeTicketRepo) Cost

func (r FreeTicketRepo) Cost(token string, bytes int) error

func (FreeTicketRepo) List

func (r FreeTicketRepo) List(token string, limit int) ([]Ticket, error)

func (FreeTicketRepo) New

func (r FreeTicketRepo) New(token string, bytes int, trade, order string) error

type Handler

type Handler struct {
	Upstream string
	Repo     TicketRepo
	AltSvc   string
}

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Order

type Order struct {
	OrderNo string
	Amount  string
	TradeNo string
}

type Pay

type Pay interface {
	NewQR(order Order, notifyURL string) (string, error)
	OnPay(req *http.Request) (Order, error)
}

func NewPay

func NewPay(appID, privateKey, publicKey string) Pay

type Ticket

type Ticket struct {
	ID         int    `db:"id" json:"id"`
	Token      string `db:"token" json:"-"`
	Bytes      int    `db:"bytes" json:"bytes"`
	TotalBytes int    `db:"total_bytes" json:"total_bytes"`
	PayOrder   string `db:"pay_order" json:"pay_order"`
	BuyOrder   string `db:"buy_order" json:"buy_order"`

	Created time.Time `db:"created" json:"created"`
	Updated time.Time `db:"updated" json:"updated"`
	Expires time.Time `db:"expires" json:"expires"`
}

func (*Ticket) KeyName

func (_ *Ticket) KeyName() string

func (*Ticket) Schema

func (t *Ticket) Schema() string

func (*Ticket) TableName

func (_ *Ticket) TableName() string

type TicketHandler

type TicketHandler struct {
	MBpCNY int
	Pay    Pay
	Repo   TicketRepo
	AltSvc string
}

func (*TicketHandler) ServeHTTP

func (h *TicketHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type TicketRepo

type TicketRepo interface {
	// New create and save one Ticket
	New(token string, bytes int, trade string, order string) error
	// Cost decreases  bytes of one Ticket
	Cost(token string, bytes int) error
	// List fetches all current Tickets with bytes available.
	List(token string, limit int) ([]Ticket, error)
}

func NewTicketRepo

func NewTicketRepo(path string) TicketRepo

Directories

Path Synopsis
cmd
zns

Jump to

Keyboard shortcuts

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