ntfy

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ntfy 托管 ntfy(binwiederhier/ntfy)自建推送服务:在界面中配置监听地址与管理员账号, 生成 server.yml 并守护 ntfy 进程;通知中心的 ntfy 渠道可直接使用本机服务。

Index

Constants

View Source
const ID = "ntfy"

ID 是模块标识。

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

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

Module 是 ntfy 模块。

func New

func New() *Module

New 创建模块。

func (*Module) ID

func (m *Module) ID() string

ID 实现 module.Module。

func (*Module) Init

func (m *Module) Init(env module.Env) error

Init 实现 module.Module。

func (*Module) ProgramInstallers

func (m *Module) ProgramInstallers() []*binstall.Installer

ProgramInstallers 返回模块托管的程序安装器,供 Gately 自动检查更新时一并检查托管程序。

func (*Module) Routes

func (m *Module) Routes(r module.Router)

Routes 实现 module.Module。

func (*Module) SetHTTPClient

func (m *Module) SetHTTPClient(fn func() *http.Client)

SetHTTPClient 实现 module.HTTPClientAware。

func (*Module) Start

func (m *Module) Start(context.Context) error

Start 实现 module.Module。

func (*Module) Stop

func (m *Module) Stop() error

Stop 实现 module.Module。

func (*Module) Summary

func (m *Module) Summary() []module.SummaryItem

Summary 实现 module.Summarizer。

func (*Module) Title

func (m *Module) Title() string

Title 实现 module.Module。

type Server

type Server struct {
	Enable bool `json:"enable"`
	// ListenIP 为空表示监听全部 IPv4 地址
	ListenIP string `json:"listenIp"`
	Port     int    `json:"port"`
	// BaseURL 是客户端访问 ntfy 的外部地址(例如经 Web 服务反向代理的域名),留空时 ntfy 使用请求中的地址;
	// 手机 App 的即时推送(iOS、Web Push)需要填写
	BaseURL string `json:"baseUrl"`
	// BehindProxy 为 true 时信任 X-Forwarded-For,仅应在反向代理之后开启
	BehindProxy bool `json:"behindProxy"`
	// AdminUser 是 Gately 管理的管理员账号,默认 admin
	AdminUser string `json:"adminUser"`
	// AdminPassword 在每次启动时同步为管理员账号的密码;留空时保存会自动生成
	AdminPassword string `json:"adminPassword"`
	// Token 是 Gately 生成的管理员访问令牌,用于通知中心的 ntfy 渠道,只读
	Token  string `json:"token"`
	Remark string `json:"remark"`
}

Server 是托管的 ntfy 服务配置。ntfy 的用户库、消息缓存都在 Gately 配置目录下的 ntfy 子目录中。

func (*Server) Config

func (s *Server) Config(dir string) ([]byte, error)

Config 生成 server.yml。dir 为数据目录,用户与令牌以声明方式写入,ntfy 每次启动时同步。

func (*Server) ListenAddr

func (s *Server) ListenAddr() string

ListenAddr 返回 ntfy 的监听地址。

func (*Server) Validate

func (s *Server) Validate() error

Validate 校验并规范化配置;管理员密码或令牌缺失时自动生成。

type ServerView

type ServerView struct {
	Server
	State proc.State `json:"state"`
	Error string     `json:"error"`
	// LocalURL 为 Gately 所在主机访问 ntfy 的地址,通知中心渠道使用
	LocalURL string `json:"localUrl"`
}

ServerView 是界面展示的服务配置与运行状态。

type Settings

type Settings struct {
	// BinPath 为空时依次在配置目录 bin 与 PATH 下查找 ntfy
	BinPath string `json:"binPath"`
}

Settings 是模块级配置。

Jump to

Keyboard shortcuts

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