Documentation ¶
Index ¶
- Constants
- Variables
- func AddFeed(wtx *bolt.Tx, chatIdentifier string, item feeds.Item) error
- func AddFeedServer(wtx *bolt.Tx, server model.Server, action ServerAction) (err error)
- func AssignSubDomain(ip netip.Addr) (err error)
- func ChooseDialer(server model.Server) netproxy.ContextDialer
- func GetCNProxyDialer() (proxy.Dialer, error)
- func GetChatFeed(tx *bolt.Tx, chatIdentifier string, format FeedFormat, fromTelegram bool) (string, error)
- func GetPassagesByServer(tx *bolt.Tx, serverTicket string) (passages []model.Passage)
- func GetServerByTicket(tx *bolt.Tx, ticket string) (server model.Server, err error)
- func GetServersByChatIdentifier(tx *bolt.Tx, chatIdentifier string, includeRelay bool) (servers []model.Server, err error)
- func GetTicketObj(tx *bolt.Tx, ticket string) (tic model.Ticket, err error)
- func GetValidTicketObj(tx *bolt.Tx, ticket string) (tic model.Ticket, err error)
- func GetValidTickets(tx *bolt.Tx) (tickets []model.Ticket)
- func NewVerification(wtx *bolt.Tx, chatIdentifier string) (verificationCode string, err error)
- func Ping(ctx context.Context, server model.Server) (*model.PingResp, error)
- func RegisterServer(wtx *bolt.Tx, server model.Server) (err error)
- func ReqSyncPassagesByChatIdentifier(tx *bolt.Tx, chatIdentifier string, includeRelay bool) (err error)
- func ReqSyncPassagesByServer(tx *bolt.Tx, serverTicket string, onlyItSelf bool) (err error)
- func RevokeTicket(wtx *bolt.Tx, ticket string, chatIdentifier string) (err error)
- func SaveTicket(wtx *bolt.Tx, ticket string, typ model.TicketType, chatIdentifier string) (tic model.Ticket, err error)
- func Verified(wtx *bolt.Tx, verificationCode string, chatIdentifier string) error
- func Verify(wtx *bolt.Tx, verificationCode string, chatIdentifier string) error
- type FeedFormat
- type ServerAction
- type ServerSyncBox
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 AddFeedServer ¶
func AssignSubDomain ¶
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 GetChatFeed ¶
func GetPassagesByServer ¶
func GetServerByTicket ¶
func GetValidTicketObj ¶
GetValidTicketObj returns ticket object if given ticket is valid
func NewVerification ¶
NewVerification generates a new verification and returns the verificationCode
func RegisterServer ¶
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 RevokeTicket ¶
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
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()
Source Files ¶
Click to show internal directories.
Click to hide internal directories.