2019-04-09 11:59:33 +00:00
|
|
|
//
|
|
|
|
// Copyright (c) 2019 Ted Unangst <tedu@tedunangst.com>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice appear in all copies.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-11-01 19:48:31 +00:00
|
|
|
"flag"
|
2019-04-09 11:59:33 +00:00
|
|
|
"fmt"
|
|
|
|
"html/template"
|
2022-02-27 20:38:19 +00:00
|
|
|
golog "log"
|
2022-03-03 20:48:45 +00:00
|
|
|
"log/syslog"
|
2019-10-29 19:53:20 +00:00
|
|
|
notrand "math/rand"
|
2019-11-01 21:36:04 +00:00
|
|
|
"os"
|
2019-10-21 06:28:35 +00:00
|
|
|
"strconv"
|
2019-10-03 04:11:02 +00:00
|
|
|
"strings"
|
2019-04-09 11:59:33 +00:00
|
|
|
"time"
|
2020-01-19 08:44:38 +00:00
|
|
|
|
|
|
|
"humungus.tedunangst.com/r/webs/httpsig"
|
2022-02-27 20:38:19 +00:00
|
|
|
"humungus.tedunangst.com/r/webs/log"
|
2019-04-09 11:59:33 +00:00
|
|
|
)
|
|
|
|
|
2019-11-09 02:15:40 +00:00
|
|
|
var softwareVersion = "develop"
|
2019-11-01 21:36:04 +00:00
|
|
|
|
2019-10-29 19:53:20 +00:00
|
|
|
func init() {
|
|
|
|
notrand.Seed(time.Now().Unix())
|
|
|
|
}
|
|
|
|
|
2019-04-09 11:59:33 +00:00
|
|
|
type WhatAbout struct {
|
2019-10-29 05:00:38 +00:00
|
|
|
ID int64
|
|
|
|
Name string
|
|
|
|
Display string
|
|
|
|
About string
|
2020-09-25 23:02:26 +00:00
|
|
|
HTAbout template.HTML
|
2020-09-25 23:09:01 +00:00
|
|
|
Onts []string
|
2019-10-29 05:00:38 +00:00
|
|
|
Key string
|
|
|
|
URL string
|
|
|
|
Options UserOptions
|
2020-01-19 08:44:38 +00:00
|
|
|
SecKey httpsig.PrivateKey
|
2019-10-29 05:00:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type UserOptions struct {
|
2023-01-26 21:38:52 +00:00
|
|
|
SkinnyCSS bool `json:",omitempty"`
|
|
|
|
OmitImages bool `json:",omitempty"`
|
|
|
|
MentionAll bool `json:",omitempty"`
|
|
|
|
InlineQuotes bool `json:",omitempty"`
|
|
|
|
Avatar string `json:",omitempty"`
|
|
|
|
Banner string `json:",omitempty"`
|
|
|
|
MapLink string `json:",omitempty"`
|
|
|
|
Reaction string `json:",omitempty"`
|
|
|
|
MeCount int64
|
|
|
|
ChatCount int64
|
2019-04-09 11:59:33 +00:00
|
|
|
}
|
|
|
|
|
2019-10-25 22:46:27 +00:00
|
|
|
type KeyInfo struct {
|
|
|
|
keyname string
|
2020-01-19 08:44:38 +00:00
|
|
|
seckey httpsig.PrivateKey
|
2019-10-25 22:46:27 +00:00
|
|
|
}
|
|
|
|
|
2019-10-25 21:31:48 +00:00
|
|
|
const serverUID int64 = -2
|
2022-12-26 18:27:39 +00:00
|
|
|
const readyLuserOne int64 = 1
|
2019-10-25 21:31:48 +00:00
|
|
|
|
2019-04-13 17:58:42 +00:00
|
|
|
type Honk struct {
|
|
|
|
ID int64
|
|
|
|
UserID int64
|
|
|
|
Username string
|
|
|
|
What string
|
|
|
|
Honker string
|
2019-06-03 04:22:00 +00:00
|
|
|
Handle string
|
2020-08-05 19:33:27 +00:00
|
|
|
Handles string
|
2019-05-15 20:27:50 +00:00
|
|
|
Oonker string
|
2019-07-05 17:07:59 +00:00
|
|
|
Oondle string
|
2019-04-13 17:58:42 +00:00
|
|
|
XID string
|
|
|
|
RID string
|
|
|
|
Date time.Time
|
|
|
|
URL string
|
|
|
|
Noise string
|
2019-05-15 20:27:50 +00:00
|
|
|
Precis string
|
2019-09-11 20:20:22 +00:00
|
|
|
Format string
|
2019-04-19 15:08:22 +00:00
|
|
|
Convoy string
|
2019-04-13 17:58:42 +00:00
|
|
|
Audience []string
|
2019-05-28 06:36:47 +00:00
|
|
|
Public bool
|
2019-05-20 14:48:02 +00:00
|
|
|
Whofore int64
|
2019-08-19 03:25:11 +00:00
|
|
|
Replies []*Honk
|
2019-08-16 19:13:33 +00:00
|
|
|
Flags int64
|
2019-09-18 19:08:50 +00:00
|
|
|
HTPrecis template.HTML
|
2019-04-13 17:58:42 +00:00
|
|
|
HTML template.HTML
|
2019-07-08 00:24:54 +00:00
|
|
|
Style string
|
2019-07-10 18:36:14 +00:00
|
|
|
Open string
|
2019-04-13 17:58:42 +00:00
|
|
|
Donks []*Donk
|
2019-08-25 03:11:53 +00:00
|
|
|
Onts []string
|
2019-09-28 04:12:50 +00:00
|
|
|
Place *Place
|
2019-10-02 21:27:29 +00:00
|
|
|
Time *Time
|
2019-11-27 19:36:29 +00:00
|
|
|
Mentions []Mention
|
2021-02-09 13:18:22 +00:00
|
|
|
Badonks []Badonk
|
|
|
|
}
|
|
|
|
|
|
|
|
type Badonk struct {
|
|
|
|
Who string
|
|
|
|
What string
|
2019-11-27 19:36:29 +00:00
|
|
|
}
|
|
|
|
|
2020-05-13 21:15:29 +00:00
|
|
|
type Chonk struct {
|
|
|
|
ID int64
|
|
|
|
UserID int64
|
|
|
|
XID string
|
|
|
|
Who string
|
|
|
|
Target string
|
|
|
|
Date time.Time
|
|
|
|
Noise string
|
|
|
|
Format string
|
2020-05-15 03:51:42 +00:00
|
|
|
Donks []*Donk
|
2020-05-13 21:15:29 +00:00
|
|
|
Handle string
|
|
|
|
HTML template.HTML
|
|
|
|
}
|
|
|
|
|
2020-05-23 23:17:30 +00:00
|
|
|
type Chatter struct {
|
|
|
|
Target string
|
|
|
|
Chonks []*Chonk
|
|
|
|
}
|
|
|
|
|
2019-11-27 19:36:29 +00:00
|
|
|
type Mention struct {
|
|
|
|
Who string
|
|
|
|
Where string
|
2019-04-09 11:59:33 +00:00
|
|
|
}
|
|
|
|
|
2022-05-31 05:07:27 +00:00
|
|
|
func (mention *Mention) IsPresent(noise string) bool {
|
|
|
|
nick := strings.TrimLeft(mention.Who, "@")
|
|
|
|
idx := strings.IndexByte(nick, '@')
|
|
|
|
if idx != -1 {
|
|
|
|
nick = nick[:idx]
|
2022-05-31 04:24:02 +00:00
|
|
|
}
|
2022-05-31 05:07:27 +00:00
|
|
|
return strings.Contains(noise, ">@"+nick) || strings.Contains(noise, "@<span>"+nick)
|
2022-05-31 04:24:02 +00:00
|
|
|
}
|
|
|
|
|
2019-10-02 21:10:01 +00:00
|
|
|
type OldRevision struct {
|
|
|
|
Precis string
|
|
|
|
Noise string
|
|
|
|
}
|
|
|
|
|
2019-08-16 19:35:12 +00:00
|
|
|
const (
|
2019-10-29 23:14:41 +00:00
|
|
|
flagIsAcked = 1
|
|
|
|
flagIsBonked = 2
|
|
|
|
flagIsSaved = 4
|
|
|
|
flagIsUntagged = 8
|
2020-01-23 23:08:15 +00:00
|
|
|
flagIsReacted = 16
|
2022-02-09 22:11:55 +00:00
|
|
|
flagIsWonked = 32
|
2019-08-16 19:35:12 +00:00
|
|
|
)
|
|
|
|
|
2019-08-19 04:01:00 +00:00
|
|
|
func (honk *Honk) IsAcked() bool {
|
|
|
|
return honk.Flags&flagIsAcked != 0
|
2019-08-16 19:35:12 +00:00
|
|
|
}
|
|
|
|
|
2019-08-24 00:43:30 +00:00
|
|
|
func (honk *Honk) IsBonked() bool {
|
|
|
|
return honk.Flags&flagIsBonked != 0
|
|
|
|
}
|
|
|
|
|
2019-10-11 20:03:17 +00:00
|
|
|
func (honk *Honk) IsSaved() bool {
|
|
|
|
return honk.Flags&flagIsSaved != 0
|
|
|
|
}
|
|
|
|
|
2019-10-29 23:14:41 +00:00
|
|
|
func (honk *Honk) IsUntagged() bool {
|
|
|
|
return honk.Flags&flagIsUntagged != 0
|
|
|
|
}
|
|
|
|
|
2020-01-23 23:08:15 +00:00
|
|
|
func (honk *Honk) IsReacted() bool {
|
|
|
|
return honk.Flags&flagIsReacted != 0
|
|
|
|
}
|
|
|
|
|
2019-04-13 17:58:42 +00:00
|
|
|
type Donk struct {
|
2020-10-01 17:18:05 +00:00
|
|
|
FileID int64
|
|
|
|
XID string
|
|
|
|
Name string
|
|
|
|
Desc string
|
|
|
|
URL string
|
|
|
|
Media string
|
|
|
|
Local bool
|
|
|
|
External bool
|
2019-04-09 11:59:33 +00:00
|
|
|
}
|
|
|
|
|
2019-09-28 04:12:50 +00:00
|
|
|
type Place struct {
|
|
|
|
Name string
|
|
|
|
Latitude float64
|
|
|
|
Longitude float64
|
2019-09-29 20:07:35 +00:00
|
|
|
Url string
|
2019-09-28 04:12:50 +00:00
|
|
|
}
|
|
|
|
|
2019-10-03 04:11:02 +00:00
|
|
|
type Duration int64
|
|
|
|
|
|
|
|
func (d Duration) String() string {
|
|
|
|
s := time.Duration(d).String()
|
|
|
|
if strings.HasSuffix(s, "m0s") {
|
|
|
|
s = s[:len(s)-2]
|
|
|
|
}
|
|
|
|
if strings.HasSuffix(s, "h0m") {
|
|
|
|
s = s[:len(s)-2]
|
|
|
|
}
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
2019-10-21 06:28:35 +00:00
|
|
|
func parseDuration(s string) time.Duration {
|
|
|
|
didx := strings.IndexByte(s, 'd')
|
|
|
|
if didx != -1 {
|
|
|
|
days, _ := strconv.ParseInt(s[:didx], 10, 0)
|
|
|
|
dur, _ := time.ParseDuration(s[didx:])
|
|
|
|
return dur + 24*time.Hour*time.Duration(days)
|
|
|
|
}
|
|
|
|
dur, _ := time.ParseDuration(s)
|
|
|
|
return dur
|
|
|
|
}
|
|
|
|
|
2019-10-02 21:27:29 +00:00
|
|
|
type Time struct {
|
|
|
|
StartTime time.Time
|
|
|
|
EndTime time.Time
|
2019-10-03 04:11:02 +00:00
|
|
|
Duration Duration
|
2019-10-02 21:27:29 +00:00
|
|
|
}
|
|
|
|
|
2019-04-13 17:58:42 +00:00
|
|
|
type Honker struct {
|
|
|
|
ID int64
|
|
|
|
UserID int64
|
|
|
|
Name string
|
|
|
|
XID string
|
2019-08-16 03:27:55 +00:00
|
|
|
Handle string
|
2019-04-13 17:58:42 +00:00
|
|
|
Flavor string
|
2019-04-22 21:03:55 +00:00
|
|
|
Combos []string
|
2019-12-04 05:44:45 +00:00
|
|
|
Meta HonkerMeta
|
2019-12-02 23:26:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type HonkerMeta struct {
|
|
|
|
Notes string
|
2019-04-09 11:59:33 +00:00
|
|
|
}
|
|
|
|
|
2019-10-26 22:31:42 +00:00
|
|
|
type SomeThing struct {
|
|
|
|
What int
|
|
|
|
XID string
|
|
|
|
Owner string
|
|
|
|
Name string
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
SomeNothing int = iota
|
|
|
|
SomeActor
|
|
|
|
SomeCollection
|
|
|
|
)
|
|
|
|
|
2019-09-10 18:43:34 +00:00
|
|
|
var serverName string
|
2020-10-01 17:18:05 +00:00
|
|
|
var serverPrefix string
|
2020-03-05 20:29:34 +00:00
|
|
|
var masqName string
|
2019-11-01 19:48:31 +00:00
|
|
|
var dataDir = "."
|
|
|
|
var viewDir = "."
|
2019-09-10 18:43:34 +00:00
|
|
|
var iconName = "icon.png"
|
2019-10-20 21:02:55 +00:00
|
|
|
var serverMsg template.HTML
|
|
|
|
var aboutMsg template.HTML
|
|
|
|
var loginMsg template.HTML
|
2019-04-09 11:59:33 +00:00
|
|
|
|
|
|
|
func ElaborateUnitTests() {
|
|
|
|
}
|
|
|
|
|
2019-12-09 00:17:38 +00:00
|
|
|
func unplugserver(hostname string) {
|
|
|
|
db := opendatabase()
|
|
|
|
xid := fmt.Sprintf("%%https://%s/%%", hostname)
|
|
|
|
db.Exec("delete from honkers where xid like ? and flavor = 'dub'", xid)
|
|
|
|
db.Exec("delete from doovers where rcpt like ?", xid)
|
|
|
|
}
|
|
|
|
|
2022-02-09 21:30:58 +00:00
|
|
|
func reexecArgs(cmd string) []string {
|
|
|
|
args := []string{"-datadir", dataDir}
|
2022-02-27 20:38:19 +00:00
|
|
|
args = append(args, log.Args()...)
|
2022-02-09 21:30:58 +00:00
|
|
|
args = append(args, cmd)
|
|
|
|
return args
|
|
|
|
}
|
|
|
|
|
2022-02-27 20:38:19 +00:00
|
|
|
var elog, ilog, dlog *golog.Logger
|
|
|
|
|
2019-04-09 11:59:33 +00:00
|
|
|
func main() {
|
2019-11-01 19:48:31 +00:00
|
|
|
flag.StringVar(&dataDir, "datadir", dataDir, "data directory")
|
|
|
|
flag.StringVar(&viewDir, "viewdir", viewDir, "view directory")
|
|
|
|
flag.Parse()
|
2022-02-06 05:42:13 +00:00
|
|
|
|
2022-03-03 20:48:45 +00:00
|
|
|
log.Init(log.Options{Progname: "honk", Facility: syslog.LOG_UUCP})
|
2022-02-27 20:38:19 +00:00
|
|
|
elog = log.E
|
|
|
|
ilog = log.I
|
|
|
|
dlog = log.D
|
2022-02-06 05:42:13 +00:00
|
|
|
|
2019-11-01 19:48:31 +00:00
|
|
|
args := flag.Args()
|
2019-04-09 11:59:33 +00:00
|
|
|
cmd := "run"
|
2019-11-01 19:48:31 +00:00
|
|
|
if len(args) > 0 {
|
|
|
|
cmd = args[0]
|
2019-04-09 11:59:33 +00:00
|
|
|
}
|
2019-04-14 20:43:03 +00:00
|
|
|
switch cmd {
|
|
|
|
case "init":
|
|
|
|
initdb()
|
|
|
|
case "upgrade":
|
|
|
|
upgradedb()
|
2019-11-01 21:36:04 +00:00
|
|
|
case "version":
|
2019-11-09 02:15:40 +00:00
|
|
|
fmt.Println(softwareVersion)
|
2019-11-01 21:36:04 +00:00
|
|
|
os.Exit(0)
|
2019-04-09 11:59:33 +00:00
|
|
|
}
|
2019-04-14 20:43:03 +00:00
|
|
|
db := opendatabase()
|
|
|
|
dbversion := 0
|
|
|
|
getconfig("dbversion", &dbversion)
|
|
|
|
if dbversion != myVersion {
|
2022-02-06 05:42:13 +00:00
|
|
|
elog.Fatal("incorrect database version. run upgrade.")
|
2019-04-14 20:43:03 +00:00
|
|
|
}
|
2019-06-12 03:11:18 +00:00
|
|
|
getconfig("servermsg", &serverMsg)
|
2019-10-20 20:28:09 +00:00
|
|
|
getconfig("aboutmsg", &aboutMsg)
|
|
|
|
getconfig("loginmsg", &loginMsg)
|
2019-04-14 20:43:03 +00:00
|
|
|
getconfig("servername", &serverName)
|
2020-03-05 20:29:34 +00:00
|
|
|
getconfig("masqname", &masqName)
|
|
|
|
if masqName == "" {
|
|
|
|
masqName = serverName
|
|
|
|
}
|
2020-10-01 17:18:05 +00:00
|
|
|
serverPrefix = fmt.Sprintf("https://%s/", serverName)
|
2019-07-23 17:21:09 +00:00
|
|
|
getconfig("usersep", &userSep)
|
|
|
|
getconfig("honksep", &honkSep)
|
2022-03-01 01:40:23 +00:00
|
|
|
getconfig("devel", &develMode)
|
2022-05-20 16:33:48 +00:00
|
|
|
getconfig("fasttimeout", &fastTimeout)
|
|
|
|
getconfig("slowtimeout", &slowTimeout)
|
2022-05-20 19:54:08 +00:00
|
|
|
getconfig("signgets", &signGets)
|
2019-04-14 20:43:03 +00:00
|
|
|
prepareStatements(db)
|
2019-04-09 11:59:33 +00:00
|
|
|
switch cmd {
|
2019-10-20 23:06:29 +00:00
|
|
|
case "admin":
|
|
|
|
adminscreen()
|
2019-11-13 00:00:00 +00:00
|
|
|
case "import":
|
|
|
|
if len(args) != 4 {
|
2022-02-06 05:42:13 +00:00
|
|
|
elog.Fatal("import username mastodon|twitter srcdir")
|
2019-11-13 00:00:00 +00:00
|
|
|
}
|
|
|
|
importMain(args[1], args[2], args[3])
|
2022-03-01 01:40:23 +00:00
|
|
|
case "devel":
|
2019-11-01 19:48:31 +00:00
|
|
|
if len(args) != 2 {
|
2022-03-01 01:40:23 +00:00
|
|
|
elog.Fatal("need an argument: devel (on|off)")
|
2019-10-20 20:39:01 +00:00
|
|
|
}
|
2019-11-01 19:48:31 +00:00
|
|
|
switch args[1] {
|
2019-10-20 20:39:01 +00:00
|
|
|
case "on":
|
2022-03-01 01:40:23 +00:00
|
|
|
setconfig("devel", 1)
|
2019-10-20 20:39:01 +00:00
|
|
|
case "off":
|
2022-03-01 01:40:23 +00:00
|
|
|
setconfig("devel", 0)
|
2019-10-20 20:39:01 +00:00
|
|
|
default:
|
2022-02-06 05:42:13 +00:00
|
|
|
elog.Fatal("argument must be on or off")
|
2019-10-20 20:39:01 +00:00
|
|
|
}
|
2022-05-20 22:48:40 +00:00
|
|
|
case "setconfig":
|
|
|
|
if len(args) != 3 {
|
|
|
|
elog.Fatal("need an argument: setconfig key val")
|
|
|
|
}
|
|
|
|
var val interface{}
|
|
|
|
var err error
|
|
|
|
if val, err = strconv.Atoi(args[2]); err != nil {
|
|
|
|
val = args[2]
|
|
|
|
}
|
|
|
|
setconfig(args[1], val)
|
2019-05-22 19:11:39 +00:00
|
|
|
case "adduser":
|
|
|
|
adduser()
|
2019-12-10 19:03:44 +00:00
|
|
|
case "deluser":
|
|
|
|
if len(args) < 2 {
|
|
|
|
fmt.Printf("usage: honk deluser username\n")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
deluser(args[1])
|
2019-10-12 23:21:29 +00:00
|
|
|
case "chpass":
|
2022-11-22 18:06:57 +00:00
|
|
|
if len(args) < 2 {
|
|
|
|
fmt.Printf("usage: honk chpass username\n")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
chpass(args[1])
|
2023-03-01 19:48:50 +00:00
|
|
|
case "follow":
|
|
|
|
if len(args) < 3 {
|
|
|
|
fmt.Printf("usage: honk follow username url\n")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
user, err := butwhatabout(args[1])
|
|
|
|
if err != nil {
|
2023-03-03 04:37:16 +00:00
|
|
|
fmt.Printf("user not found\n")
|
2023-03-01 19:48:50 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
var meta HonkerMeta
|
|
|
|
mj, _ := jsonify(&meta)
|
|
|
|
honkerid, err := savehonker(user, args[2], "", "presub", "", mj)
|
|
|
|
if err != nil {
|
2023-03-03 04:37:16 +00:00
|
|
|
fmt.Printf("had some trouble with that: %s\n", err)
|
2023-03-01 19:48:50 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
followyou(user, honkerid, true)
|
|
|
|
case "unfollow":
|
|
|
|
if len(args) < 3 {
|
|
|
|
fmt.Printf("usage: honk unfollow username url\n")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
user, err := butwhatabout(args[1])
|
|
|
|
if err != nil {
|
2023-03-03 04:37:16 +00:00
|
|
|
fmt.Printf("user not found\n")
|
2023-03-01 19:48:50 +00:00
|
|
|
return
|
|
|
|
}
|
2023-03-03 04:34:54 +00:00
|
|
|
row := db.QueryRow("select honkerid from honkers where xid = ? and userid = ? and flavor in ('sub')", args[2], user.ID)
|
2023-03-01 19:48:50 +00:00
|
|
|
var honkerid int64
|
|
|
|
err = row.Scan(&honkerid)
|
|
|
|
if err != nil {
|
2023-03-03 04:37:16 +00:00
|
|
|
fmt.Printf("sorry couldn't find them\n")
|
2023-03-01 19:48:50 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
unfollowyou(user, honkerid, true)
|
2019-05-21 18:06:17 +00:00
|
|
|
case "cleanup":
|
2019-07-16 00:49:01 +00:00
|
|
|
arg := "30"
|
2019-11-01 19:48:31 +00:00
|
|
|
if len(args) > 1 {
|
|
|
|
arg = args[1]
|
2019-06-08 18:26:30 +00:00
|
|
|
}
|
2019-07-16 00:49:01 +00:00
|
|
|
cleanupdb(arg)
|
2019-12-09 00:17:38 +00:00
|
|
|
case "unplug":
|
|
|
|
if len(args) < 2 {
|
|
|
|
fmt.Printf("usage: honk unplug servername\n")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
name := args[1]
|
|
|
|
unplugserver(name)
|
2020-09-02 21:47:18 +00:00
|
|
|
case "backup":
|
|
|
|
if len(args) < 2 {
|
|
|
|
fmt.Printf("usage: honk backup dirname\n")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
name := args[1]
|
|
|
|
svalbard(name)
|
2019-04-12 16:32:07 +00:00
|
|
|
case "ping":
|
2019-11-01 19:48:31 +00:00
|
|
|
if len(args) < 3 {
|
2020-11-11 19:44:51 +00:00
|
|
|
fmt.Printf("usage: honk ping (from username) (to username or url)\n")
|
2019-04-12 16:32:07 +00:00
|
|
|
return
|
|
|
|
}
|
2019-11-01 19:48:31 +00:00
|
|
|
name := args[1]
|
|
|
|
targ := args[2]
|
2019-04-12 16:32:07 +00:00
|
|
|
user, err := butwhatabout(name)
|
|
|
|
if err != nil {
|
2022-02-06 05:42:13 +00:00
|
|
|
elog.Printf("unknown user")
|
2019-04-12 16:32:07 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
ping(user, targ)
|
2019-04-09 11:59:33 +00:00
|
|
|
case "run":
|
|
|
|
serve()
|
2019-11-09 07:15:15 +00:00
|
|
|
case "backend":
|
|
|
|
backendServer()
|
2019-04-09 11:59:33 +00:00
|
|
|
case "test":
|
|
|
|
ElaborateUnitTests()
|
|
|
|
default:
|
2022-02-06 05:42:13 +00:00
|
|
|
elog.Fatal("unknown command")
|
2019-04-09 11:59:33 +00:00
|
|
|
}
|
|
|
|
}
|