diff options
| author | Christine Dodrill <me@christine.website> | 2018-12-09 08:52:03 -0800 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2018-12-09 08:52:30 -0800 |
| commit | 223095c3f5da5ae63cddcecdfc16f0371afa9939 (patch) | |
| tree | 985330b212a8c1b7450d773f3f9a5a1d7f5064d8 | |
| parent | d66cd9cd7505c19b76379fe18ca7dbae1ff2a4a8 (diff) | |
| download | x-223095c3f5da5ae63cddcecdfc16f0371afa9939.tar.xz x-223095c3f5da5ae63cddcecdfc16f0371afa9939.zip | |
start on manpages
| -rw-r--r-- | docs/README.md | 3 | ||||
| -rw-r--r-- | docs/man/appsluggr.1 | 113 | ||||
| -rw-r--r-- | docs/man/cadeybot.1 | 62 | ||||
| -rw-r--r-- | docs/man/ghstat.1 | 75 | ||||
| -rw-r--r-- | docs/man/ilo-kesi.1 | 130 | ||||
| -rw-r--r-- | docs/man/license.1 | 78 | ||||
| -rw-r--r-- | docs/man/routed.1 | 129 | ||||
| -rw-r--r-- | internal/manpage/gen.go | 102 | ||||
| -rw-r--r-- | tools/dbupload/.gitignore | 1 | ||||
| -rw-r--r-- | tools/dbupload/db.go | 49 | ||||
| -rw-r--r-- | tools/dbupload/dbmanifestgen/.gitignore | 1 | ||||
| l--------- | tools/dbupload/dbmanifestgen/db.go | 1 | ||||
| -rw-r--r-- | tools/dbupload/dbmanifestgen/main.go | 62 | ||||
| -rwxr-xr-x | tools/dbupload/dbsimplegen/dbsimplegen | 11 | ||||
| -rw-r--r-- | tools/dbupload/main.go | 116 | ||||
| -rw-r--r-- | tools/ghstat/main.go | 2 | ||||
| -rw-r--r-- | tools/license/main.go | 1 | ||||
| -rw-r--r-- | tools/mcrcon/.gitignore | 1 | ||||
| -rw-r--r-- | tools/mcrcon/main.go | 32 |
19 files changed, 694 insertions, 275 deletions
diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..d7861c2 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,3 @@ +# x + +This is an attempt to document the commands and tools in x. This might fail. diff --git a/docs/man/appsluggr.1 b/docs/man/appsluggr.1 new file mode 100644 index 0000000..a0f3881 --- /dev/null +++ b/docs/man/appsluggr.1 @@ -0,0 +1,113 @@ +.Dd December 09, 2018 +.Dt APPSLUGGR 1 URM + + +.Sh NAME +.Nm appsluggr +.Nd appsluggr packages a precompiled binary application as a Heroku style slug for use with Dokku. + + +.Sh SYNOPSIS +.Nm + +.Op Fl fname +.Op Fl license +.Op Fl web +.Op Fl web-scale +.Op Fl worker +.Op Fl worker-scale + + +.Sh DESCRIPTION +.Nm +is a small tool to package +.Li GOOS=linux GOARCH=amd64 +binaries for consumption on +.Li hyperlink: http://dokku.viewdocs.io/dokku/ Dokku +. + +.Bl -tag -width " " -offset indent -compact + +.It Fl fname +The filename to write the resulting slug to. + +The default value for this is +.Li slug.tar.gz +. + +.It Fl license +If set, the tool will show its software license details and then exit. + +.It Fl web +The path to the binary for the web process. + +One of +.Fl web +or +.Fl worker +must be set. + +.It Fl web-scale +The default scale for web process if defined. + +The default value for this is 1. + +.It Fl worker +The path to the binary for the worker process. +One of +.Fl web +or +.Fl worker +must be set. + +.It Fl worker-scale +The default scale for the worker process if defined. + +The default value for this is 1 + +.El + + +.Sh EXAMPLES + +.Li appsluggr + +.Li appsluggr -web web + +.Li appsluggr -worker ilo-sona + +.Li appsluggr -fname foo.tar.gz -web web -worker worker -web-scale 4 -worker-scale 16 + + +.Sh IMPLEMENTATION NOTES + +.Nm +when used with +.Lk hyperlink: http://dokku.viewdocs.io/dokku/ Dokku +requires the use of the +.Lk hyperlink: https://github.com/ryandotsmith/null-buildpack Null Buildpack +as follows: + +.Li $ dokku config:set $APP_NAME BUILDPACK_URL=https://github.com/ryandotsmith/null-buildpack + +Or + +.Li $ ssh dokku@host config:set <see above> + + +.Sh DIAGNOSTICS + +.Ex -std appsluggr + + +.Sh SEE ALSO + +.Bl -bullet + +.It +.Lk hyperlink: http://dokku.viewdocs.io/dokku/ Dokku + +.It +.Lk hyperlink: https://github.com/ryandotsmith/null-buildpack Null Buildpack + +.El diff --git a/docs/man/cadeybot.1 b/docs/man/cadeybot.1 new file mode 100644 index 0000000..e1d1967 --- /dev/null +++ b/docs/man/cadeybot.1 @@ -0,0 +1,62 @@ +.Dd December 19, 2018 +.Dt CADEYBOT 1 URM + + +.Sh NAME +.Nm cadeybot +.Nd Markov bot based on my discord GDPR dump. + + +.Sh SYNOPSIS +.Nm +.Op Fl token Ar TOKEN +.Op Fl brain Ar BRAIN + + +.Sh DESCRIPTION +.Nm +is a simple markov chatbot. Mention it in any channel the bot is in to make it spew out amusing text. + +.Bl -tag -width " " -offset indent -compact + +.It Ev TOKEN Fl token Ar TOKEN +Specifies the Discord token that +.Nm +will use for client communication. + +.It Ev BRAIN Fl token Ar TOKEN +Specifies the Markov chain brain that +.Nm +should load data into cadey.gob from. + +.El + + +.Sh IMPLEMENTATION NOTES + +In order for +.Nm +to get markov bot data, please put the importer tool and corpusmake.sh into the messages folder of your Discord GDPR dump. Then run corpusmake.sh and pass the resulting brain.txt as -brain to +.Nm . + + +.Sh EXAMPLES + +.Li cadeybot + +.Li cadeybot -brain brain.txt + + +.Sh DIAGNOSTICS + +.Ex -std cadeybot + + +.Sh SEE ALSO + +.Bl -bullet + +.It +.Lk hyperlink: https://discordapp.com Discord + +.El diff --git a/docs/man/ghstat.1 b/docs/man/ghstat.1 new file mode 100644 index 0000000..694c72e --- /dev/null +++ b/docs/man/ghstat.1 @@ -0,0 +1,75 @@ +.Dd December 09, 2018 +.Dt GHSTAT 1 URM + + +.Sh NAME +.Nm ghstat +.Nd Look up and summarize the status of GitHub. + + +.Sh SYNOPSIS +.Nm +.Op Fl license +.Op Fl message + + + +.Sh DESCRIPTION +.Nm +is a small tool to help users look up information about +.Lk hyperlink: https://github.com GitHub +system status as viewed by their +.Lk hyperlink: https://status.github.com Status API +. + +By default this tool will print a very small summary of GitHub status followed by the time the last update was made in RFC 3339 time format. + +Here's an example: + +.Li $ ghstat +.Li Status: good (2018-12-06T17:09:57Z) + +.Bl -tag -width " " -offset indent -compact + +.It Fl license +If set, the tool will show its software license details and then exit. + +.It Fl message +If set, the tool will show the last status message from GitHub more verbosely like such: + +.Li $ ghstat -message +.Li Last message: +.Li Status: good +.Li Message: +.Li Time: + +When there is a message relevant to the status, it and its time will be shown here. + +.El + + +.Sh EXAMPLES + +.Li ghstat + +.Li ghstat -license + +.Li ghstat -message + + +.Sh DIAGNOSTICS + +.Ex -std ghstat + + +.Sh SEE ALSO + +.Bl -bullet + +.It +.Lk hyperlink: https://github.com GitHub + +.It +.Lk hyperlink: https://status.github.com GitHub Status + +.El diff --git a/docs/man/ilo-kesi.1 b/docs/man/ilo-kesi.1 new file mode 100644 index 0000000..93f26f7 --- /dev/null +++ b/docs/man/ilo-kesi.1 @@ -0,0 +1,130 @@ +.Dd December 19, 2018 +.Dt ILO-KESI 1 URM + + +.Sh NAME +.Nm ilo-kesi +.Nd ni li ilo sona pi toki pona. + + +.Sh SYNOPSIS +.Nm +.Op Fl repl Ar TOKEN + + +.Sh DESCRIPTION +.Nm +communicates with Discord and scans every message in every channel it is in for the following pattern: + +.Li ilo ${ILO_NIMI} o + +This is usually: + +.Li ilo Kesi o + +When this condition is met, the chat message will be posted to the +.Ev TOKI_PONA_TOKENIZER_API_URL +and the resulting parsed sentences will be analyzed for what is being asked, and then it will be done. + +This only works on sentences written in the +.Lk hyperlink http://tokipona.org Toki Pona +constructed language. + +.Bl -tag -width "routed" -offset -indent -compact + +.It Fl repl Ar REPL +When this flag is passed, +.Nm +will function in a mode where it does not connect to discord. This is useful when debugging parts of the grammar parsing. You can pass a junk value to +.Ev DISCORD_TOKEN +to help make testing easier. + +.El + + +.Sh ENVIRONMENT + +.Bl -tag -width " " -offset indent -compact + +.It Ev DISCORD_TOKEN +Specifies the Discord token that +.Nm +will use for client communication. + +.It Ev TOKI_PONA_TOKENIZER_API_URL +Specifies the URL that +.Nm +will use to tokenize Toki Pona sentences. This should be some instance of the following serverless function: + +.Lk hyperlink: https://github.com/Xe/x/blob/master/discord/ilo-kesi/function/index.js + +The default value for this is: + +.Lk hyperlink: https://us-central1-golden-cove-408.cloudfunctions.net/function-1 + +.It Ev SWITCH_COUNTER_WEBHOOK +Specifies the URL that +.Nm +will use to communicate with +.Lk hyperlink: https://www.switchcounter.science Switch Counter +. +This will be used mainly to read data, unless the user in question is a member of the +.Ev JAN_LAWA +id set. + +.It Ev ILO_NIMI +Specifies the name of +.Nm +when being commanded to do stuff. This defaults to +.Li Kesi +. + +.It JAN_LAWA +Specifies the list of people (via Discord user ID's) that are allowed to use +.Nm +to submit switch data to +.Lk hyperlink: https://www.switchcounter.science Switch Counter +. + +.El + + +.Sh IMPLEMENTATION NOTES + +.Nm +requires a brain created by +.Xr cadeybot 1 +. + +.Nm +requires a webhook from +.Lk hyperlink: https://www.switchcounter.science Switch Counter +. + + +.Sh EXAMPLES + +ilo-kesi + +ilo-kesi -repl + + +.Sh DIAGNOSTICS + +.Ex -std ilo-kesi + + +.Sh SEE ALSO + +.Bl -bullet + +.It +.Lk hyperlink: https://discordapp.com Discord + +.It +.Lk hyperlink http://tokipona.org Toki Pona + +.It +.Lk hyperlink: https://www.switchcounter.science Switch Counter + +.El diff --git a/docs/man/license.1 b/docs/man/license.1 new file mode 100644 index 0000000..be89302 --- /dev/null +++ b/docs/man/license.1 @@ -0,0 +1,78 @@ +.Dd December 09, 2018 +.Dt LICENSE 1 URM + + +.Sh NAME +.Nm license +.Nd Generate software licenses from a rather large list of templates. + + +.Sh SYNOPSIS +.Nm +.Op Fl email +.Op Fl license +.Op Fl name +.Op Fl out +.Op Fl show + + +.Sh DESCRIPTION +.Nm +is a software license generator. It uses +.Xr git-config 1 +to parse out your email and "real name" when relevant for the license template reasons. + + +.Bl -tag -width " " -offset indent -compact + + +.It Fl email +The email of the person licensing the software. This should be your email, or a corporation's email. If in doubt, ask a lawyer what to put here. + +The default value for this is derived from +.Xr git-config 1 +by using the command: + +.Li $ git config user.email + +.It Fl license +If set, +.Nm +will show its software license details and then exit. + +.It Fl name +The name of the person licensing the software. This should be your name, or a corporation's name. If in doubt, ask a lawyer what to put here. + +The default value for this is derived from +.Xr git-config 1 +by using the command: + +.Li $ git config user.name + +.It Fl out +If this is set, +.Nm +will write the resulting license to the disk instead of standard out. + +.It Fl show +If set, +.Nm +will show its list of license templates instead of generating one. + +.El + + +.Sh EXAMPLES + +.Li license + +.Li license -license + +.Li license -show + +.Li license mit + + +.Sh DIAGNOSTICS + +.Ex -std license diff --git a/docs/man/routed.1 b/docs/man/routed.1 new file mode 100644 index 0000000..14736b1 --- /dev/null +++ b/docs/man/routed.1 @@ -0,0 +1,129 @@ +.Dd December 12, 2017 +.Dt ROUTED 1 URM + + +.Sh NAME +.Nm routed +.Nd TLS termination and reverse reverse proxying daemon. + + +.Sh SYNOPSIS +.Nm + + +.Sh ENVIRONMENT + +.Bl -tag -width "routed" -offset indent -compact + +.It Ev BOLTDB_PATH +Specifies the path to the boltdb database +.Nm +stores all of its relevant data in. + +.It Ev WEB_ADDR +Specifies the host+port that +.Nm +will listen on for unsecured HTTP traffic. This will only forward traffic to HTTPS. + +.It Ev SSL_ADDR +Specifies the host+port that +.Nm +will listen on for secure (TLS) traffic. This should have port 443 if you want Let's Encrypt to work (you probably want Let's Encrypt to work). + +.It Ev QUIC_ADDR +Specifies the host+port that +.Nm +will listen on for secure (TLS) QUIC traffic. For more information see https://datatracker.ietf.org/wg/quic/about/. This should also be port 443, but is not essential for Let's Encrypt to work. + +.It Ev BACKEND_TCP_ADDR +Specifies the host+port that +.Nm +will listen on for secure (TLS) TCP connections from backends. Any client that is successfully able to authenticate with +.Nm +on this port will relay HTTP traffic from to and from end users. + +.It Ev BACKEND_KCP_ADDR +Specifies the host+port that +.Nm +will listen on for secure (TLS) KCP (reliable-UDP) connections from backends. Any client that is successfully able to authenticate with +.Nm +on this port will relay HTTP traffic from to and from end users. + +For more information about KCP, see https://github.com/xtaci/kcp-go + +.It Ev GRPC_ADDR +Specifies the host+post that +.Nm +will listen on for secure (TLS) TCP gRPC connections from clients wishing to control +.Nm +configuration. Authentication is enforced and requires the use of an API token generated by the API call route.Tokens.Put. + +.It Ev DOMAIN_SUFFIX +Specifies the domain suffix that +.Nm +will use when automatically generating a domain name for a newly created route. Please set this to something that has a wildcard DNS record pointing to your instances of routed. + +.It Ev ACME_EMAIL +Specifies the email address that +.Nm +will use when creating a new account with Let's Encrypt. This assumes you have read (and agree to) the Let's Encrypt terms of service found here: https://letsencrypt.org/documents/LE-SA-v1.0.1-July-27-2015.pdf. + +.It Ev SSL_CERT_KEY +Specifies the encryption key that +.Nm +will use when encrypting and decrypting SSL certificates when loading them from and saving them to the database. This can be created with +.Xr route-cli 1 . + +.El + + +.Sh IMPLEMENTATION NOTES + +In order for +.Nm +to route traffic, a route must be set up using +.Xr route-cli 1 . +Please see its manpage for more information on how to do this. + +.Nm +exposes debugging and introspection information on a randomly generated port every time it starts up. The message will look something like: + +2017/12/13 02:06:56 manhole: Now listening on http://127.0.0.1:39245 + +Expose this using +.Xr route-httpagent 1 +or similar tools. + +.Nm +can be managed using terraform. See +.Xr terraform-provider-route 1 +for more information. + + +.Sh EXAMPLES + +routed + + +.Sh DIAGNOSTICS + +.Ex -std routed + + +.Sh SEE ALSO + +.Bl -bullet + +.It +https://datatracker.ietf.org/wg/quic/about/ + +.It +https://github.com/xtaci/kcp-go + +.It +https://grpc.io/ + +.It +https://letsencrypt.org/documents/LE-SA-v1.0.1-July-27-2015.pdf + +.El diff --git a/internal/manpage/gen.go b/internal/manpage/gen.go new file mode 100644 index 0000000..94a3ccf --- /dev/null +++ b/internal/manpage/gen.go @@ -0,0 +1,102 @@ +package manpage + +import ( + "flag" + "html/template" + "log" + "os" + "path/filepath" + "strings" + "time" +) + +// DateFormat is the date format used in manpages. +const DateFormat = "January 02, 2006" + +// Spew spews out a manpage template for this program then stops execution. +func Spew() { + var result struct { + Flags []*flag.Flag + Name string + UName string + Date string + } + + result.Name = filepath.Base(os.Args[0]) + result.UName = strings.ToUpper(result.Name) + result.Date = time.Now().Format(DateFormat) + + flag.VisitAll(func(f *flag.Flag) { + result.Flags = append(result.Flags, f) + }) + + var err error + t := template.New("manpage.1") + t, err = t.Parse(manpageTemplate) + if err != nil { + log.Fatal(err) + } + + err = t.Execute(os.Stdout, result) + if err != nil { + log.Fatal(err) + } + + os.Exit(0) +} + +const manpageTemplate = `.Dd {{.Date}} +.Dt {{ .UName }} 1 URM + + +.Sh NAME +.Nm {{ .Name }} +.Nd This is a command that needs a description. + + +.Sh SYNOPSIS +.Nm +{{ range .Flags }} +.Op Fl {{ .Name }} +{{ end }} + + +.Sh DESCRIPTION +.Nm +is + +TODO: FIXME + +.Bl -tag -width " " -offset indent -compact + +{{ range .Flags }} +.It Fl {{ .Name }} +{{ .Usage }} + +The default value for this is {{ .DefValue }} +{{ end }} + +.El + + +.Sh EXAMPLES + +.Li {{ .Name }} + +.Li {{ .Name }} -license + + +.Sh DIAGNOSTICS + +.Ex -std {{ .Name }} + + +.Sh SEE ALSO + +.Bl -bullet + +.It +.Lk hyperlink: http://some.domain Some Text + +.El +` diff --git a/tools/dbupload/.gitignore b/tools/dbupload/.gitignore deleted file mode 100644 index fa5221a..0000000 --- a/tools/dbupload/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dbupload diff --git a/tools/dbupload/db.go b/tools/dbupload/db.go deleted file mode 100644 index 5307d04..0000000 --- a/tools/dbupload/db.go +++ /dev/null @@ -1,49 +0,0 @@ -package main - -type UploadImage struct { - Image struct { - SourceURL string `json:"source_url"` - Tags string `json:"tag_list"` - ImageURL string `json:"image_url"` - } `json:"image"` -} - -type Image struct { - ID string `json:"id"` - IDNumber int `json:"id_number"` - CreatedAt string `json:"created_at"` - UpdatedAt string `json:"updated_at"` - DuplicateReports []interface{} `json:"duplicate_reports"` - FileName string `json:"file_name"` - Description string `json:"description"` - Uploader string `json:"uploader"` - Image string `json:"image"` - Score int `json:"score"` - Upvotes int `json:"upvotes"` - Downvotes int `json:"downvotes"` - Faves int `json:"faves"` - CommentCount int `json:"comment_count"` - Tags string `json:"tags"` - TagIds []string `json:"tag_ids"` - Width int `json:"width"` - Height int `json:"height"` - AspectRatio float64 `json:"aspect_ratio"` - OriginalFormat string `json:"original_format"` - MimeType string `json:"mime_type"` - Sha512Hash string `json:"sha512_hash"` - OrigSha512Hash string `json:"orig_sha512_hash"` - SourceURL string `json:"source_url"` - License string `json:"license"` - Representations struct { - ThumbTiny string `json:"thumb_tiny"` - ThumbSmall string `json:"thumb_small"` - Thumb string `json:"thumb"` - Small string `json:"small"` - Medium string `json:"medium"` - Large string `json:"large"` - Tall string `json:"tall"` - Full string `json:"full"` - } `json:"representations"` - IsRendered bool `json:"is_rendered"` - IsOptimized bool `json:"is_optimized"` -} diff --git a/tools/dbupload/dbmanifestgen/.gitignore b/tools/dbupload/dbmanifestgen/.gitignore deleted file mode 100644 index fb82ff6..0000000 --- a/tools/dbupload/dbmanifestgen/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dbmanifestgen diff --git a/tools/dbupload/dbmanifestgen/db.go b/tools/dbupload/dbmanifestgen/db.go deleted file mode 120000 index 18b3e05..0000000 --- a/tools/dbupload/dbmanifestgen/db.go +++ /dev/null @@ -1 +0,0 @@ -../db.go
\ No newline at end of file diff --git a/tools/dbupload/dbmanifestgen/main.go b/tools/dbupload/dbmanifestgen/main.go deleted file mode 100644 index c5bbb2b..0000000 --- a/tools/dbupload/dbmanifestgen/main.go +++ /dev/null @@ -1,62 +0,0 @@ -package main - -import ( - "encoding/json" - "flag" - "fmt" - "io/ioutil" - "log" - "os" - "path/filepath" - "strings" -) - -var ( - serverloc = flag.String("serverloc", "http://static.xeserv.us/", "server to prepend to url paths") - sourceloc = flag.String("sourceloc", "", "source URL for metadata generation") - set = flag.String("set", "", "comic set") -) - -func main() { - flag.Parse() - - if flag.NArg() == 0 { - fmt.Printf("%s: <dir>\n", os.Args[0]) - flag.Usage() - } - - if *sourceloc == "" { - log.Fatal("Need a source location") - } - - images, err := ioutil.ReadDir(flag.Arg(0)) - if err != nil { - panic(err) - } - - for _, image := range images { - if strings.HasSuffix(image.Name(), ".json") { - log.Printf("Skipped %s...", image) - continue - } - - fout, err := os.Create(image.Name() + ".json") - - var i UploadImage - i.Image.SourceURL = *sourceloc - i.Image.ImageURL = *serverloc + filepath.Base(image.Name()) - i.Image.Tags = "explicit" - - if *set != "" { - i.Image.Tags = i.Image.Tags + ", comic:" + *set - } - - outdata, err := json.MarshalIndent(&i, "", "\t") - if err != nil { - panic(err) - } - - fout.Write(outdata) - fout.Close() - } -} diff --git a/tools/dbupload/dbsimplegen/dbsimplegen b/tools/dbupload/dbsimplegen/dbsimplegen deleted file mode 100755 index e8939e8..0000000 --- a/tools/dbupload/dbsimplegen/dbsimplegen +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -cat << EOF -{ - "image": { - "source_url": "$1", - "tag_list": "$2", - "image_url": "$3" - } -} -EOF diff --git a/tools/dbupload/main.go b/tools/dbupload/main.go deleted file mode 100644 index cc07cd7..0000000 --- a/tools/dbupload/main.go +++ /dev/null @@ -1,116 +0,0 @@ -package main - -import ( - "bytes" - "encoding/json" - "flag" - "fmt" - "io" - "io/ioutil" - "log" - "net/http" - "os" - "strings" - "time" -) - -var ( - apiKeyLocation = flag.String("apikeyloc", "/home/xena/.local/share/within/db.key", "Derpibooru API key location") - cookieLocation = flag.String("cookieloc", "/home/xena/.db.cookie", "Location for magic cookie") -) - -func main() { - flag.Parse() - - if flag.NArg() == 0 { - fmt.Printf("%s: <image to upload>\n", os.Args[0]) - fmt.Printf("All files must have a manifest json file.\n") - flag.Usage() - } - - dbkey, err := ioutil.ReadFile(*apiKeyLocation) - if err != nil { - panic(err) - } - - mydbkey := strings.Split(string(dbkey), "\n")[0] - - cookie, err := ioutil.ReadFile(*cookieLocation) - if err != nil { - panic(err) - } - - image := flag.Arg(0) - - if strings.HasSuffix(image, ".json") { - log.Printf("Skipped %s...", image) - return - } - - metafin, err := os.Open(image + ".json") - if err != nil { - log.Fatal("image " + image + " MUST have description manifest for derpibooru") - } - defer metafin.Close() - - metabytes, err := ioutil.ReadAll(metafin) - if err != nil { - log.Fatal(err) - } - - var meta UploadImage - err = json.Unmarshal(metabytes, &meta) - if err != nil { - log.Fatal(err) - } - - imfin, err := os.Open(image) - if err != nil { - log.Fatal("cannot open " + image) - } - defer imfin.Close() - - if meta.Image.ImageURL == "" { - panic("need file uploaded somewhere?") - } - - outmetabytes, err := json.Marshal(&meta) - - req, err := http.NewRequest("POST", "https://derpibooru.org/images.json?key="+mydbkey, bytes.NewBuffer(outmetabytes)) - if err != nil { - panic(err) - } - - c := &http.Client{} - - req.Header = http.Header{ - "User-Agent": {"Xena's crappy upload tool"}, - "Cookie": {string(cookie)}, - "Content-Type": {"application/json"}, - } - - resp, err := c.Do(req) - if err != nil { - log.Printf("%#v", err) - fmt.Printf("Request ID: %s\n", resp.Header.Get("X-Request-Id")) - return - } - - if resp.StatusCode != 201 { - io.Copy(os.Stdout, resp.Body) - return - } - - respbytes, err := ioutil.ReadAll(resp.Body) - if err != nil { - log.Println(err) - return - } - - var i Image - json.Unmarshal(respbytes, &i) - - fmt.Printf("Uploaded as https://derpibooru.org/%d\n", i.IDNumber) - - time.Sleep(20 * time.Second) -} diff --git a/tools/ghstat/main.go b/tools/ghstat/main.go index 91f260d..2185d93 100644 --- a/tools/ghstat/main.go +++ b/tools/ghstat/main.go @@ -8,6 +8,7 @@ import ( "net/http" "os" + "github.com/Xe/x/internal" "github.com/Xe/x/web/ghstat" ) @@ -20,6 +21,7 @@ var ( func main() { flag.Parse() + internal.HandleLicense() if *messageFlag { req := ghstat.LastMessage() diff --git a/tools/license/main.go b/tools/license/main.go index 6840912..881ebbd 100644 --- a/tools/license/main.go +++ b/tools/license/main.go @@ -35,7 +35,6 @@ func init() { func main() { flag.Parse() - internal.HandleLicense() if *showAll { diff --git a/tools/mcrcon/.gitignore b/tools/mcrcon/.gitignore deleted file mode 100644 index 9247261..0000000 --- a/tools/mcrcon/.gitignore +++ /dev/null @@ -1 +0,0 @@ -mcrcon diff --git a/tools/mcrcon/main.go b/tools/mcrcon/main.go deleted file mode 100644 index 1c5ebd6..0000000 --- a/tools/mcrcon/main.go +++ /dev/null @@ -1,32 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "log" - "strings" - - "github.com/bearbin/mcgorcon" -) - -var ( - host = flag.String("host", "127.0.0.1", "server hostname") - port = flag.Int("port", 25575, "rcon port") - password = flag.String("pass", "swag", "rcon password") -) - -func main() { - flag.Parse() - - client, err := mcgorcon.Dial(*host, *port, *password) - if err != nil { - log.Fatal(err) - } - - data, err := client.SendCommand(strings.Join(flag.Args(), " ")) - if err != nil { - log.Fatal(err) - } - - fmt.Println(data) -} |
