-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrpic.go
138 lines (117 loc) · 3.08 KB
/
rpic.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package main
const (
APP_ADDRESS = "0.0.0.0"
APP_ADMIN = "admin"
APP_ADMIN_PASSWORD = "rooster2#"
APP_NAME = "rpic"
APP_PORT = "9008"
APP_VERSION = "1.0"
)
const (
DEFAULT_CONF = ".rpic"
DEFAULT_DATABASE = "./rpic.db"
DEFAULT_DATABASE_DRIVER = "sqlite"
)
const (
PARAM_METHOD = "method"
PARAM_NAME = "name"
PARAM_PASS = "pass"
PARAM_USER = "user"
)
const (
DBUS_LOGIN = "org.freedesktop.login1"
DBUS_LOGIN_MANAGER = "org.freedesktop.login1.Manager"
DBUS_LOGIN_PATH = "/org/freedesktop/login1"
DBUS_MANAGER = "Manager"
DBUS_PROPERTIES_GET = "org.freedesktop.DBus.Properties.Get"
DBUS_PROPERTIES_GETALL = "org.freedesktop.DBus.Properties.GetAll"
DBUS_SYSTEMD = "org.freedesktop.systemd1"
DBUS_SYSTEMD_MANAGER = "org.freedesktop.systemd1.Manager"
DBUS_SYSTEMD_UNIT = "org.freedesktop.systemd1.Unit"
DBUS_SYSTEMD_PATH = "/org/freedesktop/systemd1"
DBUS_UNIT = "Unit"
)
const (
LOGIN_POWEROFF = "PowerOff"
LOGIN_REBOOT = "Reboot"
)
const (
SYSTEMD_UNIT_RESTART = "RestartUnit"
SYSTEMD_UNIT_START = "StartUnit"
SYSTEMD_UNIT_STOP = "StopUnit"
SYSTEMD_UNIT_GET = "GetUnit"
SYSTEMD_GET = "Get"
)
const (
SYSTEMD_UNIT_MODE_REPLACE = "replace"
)
const (
PROPERTY_ACTIVESTATE = "ActiveState"
)
const (
UNIT_STATE_ACTIVATING = "activating"
UNIT_STATE_ACTIVE = "active"
UNIT_STATE_FAILED = "failed"
UNIT_STATE_INACTIVE = "inactive"
UNIT_STATE_RELOADING = "reloading"
)
const (
WIREGUARD = "wireguard"
)
const (
SERVICE_WIREGUARD = "[email protected]"
)
const (
HTTP_CONTENT_TYPE = "Content-Type"
)
const (
CONTENT_TYPE_JSON = "application/json"
)
const (
STR_SPACE = " "
STR_EMPTY = ""
STR_PERIOD = "."
)
const (
MAX_TIMEOUT = 5
)
const (
CSS_DIR = "/css"
FORWARD_SLASH = "/"
INDEX_PAGE = "index"
JS_DIR = "/js"
PWD = "."
ROOT_DIR = "www"
WEB_ASSETS = "/assets/"
)
const (
BLOCK_KEY = "0123456789654321"
HASH_LENGTH = 32
HMAC_KEY = "i love raspberry pi"
IV = "abcdef ghijklmno"
SALT = "random words in a row"
SALT2 = "abcdefghijkm"
TOKEN_LENGTH = 48
)
const (
ERR_CONF_EXISTS =
"Config file exists and will not be overwritten"
ERR_CONFIG_NOT_FOUND =
"Config file not found"
ERR_DATABASE_CONNECTION =
"Unable to connect to database"
ERR_DATABASE_NOT_INITIALIZED =
"Database has not been initialized"
ERR_EMPTY_USER_NAME =
"User query cannot search for an empty name"
ERR_EMPTY_USER_TOKEN =
"User query cannot search for an empty token"
ERR_INVALID_USER_NAME =
"Invalid user name"
ERR_USER_INVALID =
"Inavlid user"
ERR_INVALID_PASSWORD =
"Invalid password"
ERR_USER_ADMIN_NOT_EXIST =
"admin user does not exist"
)