service

package
v0.0.0-...-c5d1e48 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerActionLaunch             ServerAction = "🚀 Launched"
	ServerActionReconnect                       = "🀄️ Reconnected"
	ServerActionDisconnect                      = "💥 Disconnected"
	ServerActionBandwidthExhausted              = "🈳 Bandwidth Exhausted"
	ServerActionBandwidthReset                  = "🈵 Bandwidth Reset"
	ServerActionServerInfoChanged               = "🎲 Server Info Changed"
)
View Source
const ServerSyncBoxCleanTimeout = 6 * time.Hour

Variables

View Source
var CNProxyNotSetErr = fmt.Errorf("cnproxy is not set")
View Source
var DefaultServerSyncBox = NewServerSyncBox()
View Source
var ErrInvalidTicket = fmt.Errorf("invalid ticket")

Functions

func AddFeed

func AddFeed(wtx *bolt.Tx, chatIdentifier string, item feeds.Item) error

func AddFeedServer

func AddFeedServer(wtx *bolt.Tx, server model.Server, action ServerAction) (err error)

func AssignSubDomain

func AssignSubDomain(ip netip.Addr) (err error)

func ChooseDialer

func ChooseDialer(server model.Server) netproxy.ContextDialer

ChooseDialer choose CNProxy dialer for servers in China, and net.Dialer for others

func GetCNProxyDialer

func GetCNProxyDialer() (proxy.Dialer, error)

func GetChatFeed

func GetChatFeed(tx *bolt.Tx, chatIdentifier string, format FeedFormat, fromTelegram bool) (string, error)

func GetPassagesByServer

func GetPassagesByServer(tx *bolt.Tx, serverTicket string) (passages []model.Passage)

func GetServerByTicket

func GetServerByTicket(tx *bolt.Tx, ticket string) (server model.Server, err error)

func GetServersByChatIdentifier

func GetServersByChatIdentifier(tx *bolt.Tx, chatIdentifier string, includeRelay bool) (servers []model.Server, err error)

func GetTicketObj

func GetTicketObj(tx *bolt.Tx, ticket string) (tic model.Ticket, err error)

func GetValidTicketObj

func GetValidTicketObj(tx *bolt.Tx, ticket string) (tic model.Ticket, err error)

GetValidTicketObj returns ticket object if given ticket is valid

func GetValidTickets

func GetValidTickets(tx *bolt.Tx) (tickets []model.Ticket)

func NewVerification

func NewVerification(wtx *bolt.Tx, chatIdentifier string) (verificationCode string, err error)

NewVerification generates a new verification and returns the verificationCode

func Ping

func Ping(ctx context.Context, server model.Server) (*model.PingResp, error)

func RegisterServer

func RegisterServer(wtx *bolt.Tx, server model.Server) (err error)

RegisterServer save the server in db

func ReqSyncPassagesByChatIdentifier

func ReqSyncPassagesByChatIdentifier(tx *bolt.Tx, chatIdentifier string, includeRelay bool) (err error)

ReqSyncPassagesByChatIdentifier costs long time, thus tx here should be nil.

func ReqSyncPassagesByServer

func ReqSyncPassagesByServer(tx *bolt.Tx, serverTicket string, onlyItSelf bool) (err error)

func RevokeTicket

func RevokeTicket(wtx *bolt.Tx, ticket string, chatIdentifier string) (err error)

func SaveTicket

func SaveTicket(wtx *bolt.Tx, ticket string, typ model.TicketType, chatIdentifier string) (tic model.Ticket, err error)

SaveTicket saves the given ticket to the database and sets the expiration time to the next month

func Verified

func Verified(wtx *bolt.Tx, verificationCode string, chatIdentifier string) error

Verified check if given verificationCode and chatIdentifier verification has passed

func Verify

func Verify(wtx *bolt.Tx, verificationCode string, chatIdentifier string) error

Verify verifies if given verificationCode and chatIdentifier can pass the verification

Types

type FeedFormat

type FeedFormat int
const (
	FeedFormatRSS FeedFormat = iota
	FeedFormatAtom
	FeedFormatJSON
)

type ServerAction

type ServerAction string

type ServerSyncBox

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

func NewServerSyncBox

func NewServerSyncBox() *ServerSyncBox

func (*ServerSyncBox) CleanBackground

func (b *ServerSyncBox) CleanBackground()

func (*ServerSyncBox) Close

func (b *ServerSyncBox) Close() error

func (*ServerSyncBox) ReqSync

func (b *ServerSyncBox) ReqSync(serverTicket string)

func (*ServerSyncBox) SyncBackground

func (b *ServerSyncBox) SyncBackground()

Jump to

Keyboard shortcuts

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