Compare commits

..

60 Commits

Author SHA1 Message Date
Jeff Carr 96ea435179 back to a common Init() 2025-09-11 04:38:33 -05:00
Jeff Carr c638819b00 new init() and config() 2025-09-11 03:36:40 -05:00
Jeff Carr 735bfd8122 start /lookup 2025-06-30 08:44:44 -05:00
Jeff Carr 7458af2162 autogenpb syntax change 2025-06-30 07:56:16 -05:00
Jeff Carr b09306940e patch handling now at forge.wit.com 2025-06-30 07:53:48 -05:00
Jeff Carr 40689e8761 show dev version 2025-02-09 16:16:48 -06:00
Jeff Carr dc905f7a39 remove hack that should have been in the repomap file 2025-01-30 19:48:15 -06:00
Jeff Carr 782817521c add /GetPatchsets 2025-01-30 19:48:15 -06:00
Jeff Carr ad52b03d8f better filename 2025-01-30 19:48:15 -06:00
Jeff Carr aab8d232b5 should show patch author? 2025-01-19 10:48:35 -06:00
Jeff Carr 7fa4889dce .proto changes 2025-01-13 08:11:56 -06:00
Jeff Carr 73ef74d479 show the git author and email 2024-12-29 21:36:59 -06:00
Jeff Carr 20ea487d06 show the patch names 2024-12-28 20:02:07 -06:00
Jeff Carr 7a8f54a192 compute the timestamps each time 2024-12-28 20:01:58 -06:00
Jeff Carr 37500b9496 wrong lookup. must use gopath 2024-12-18 03:35:08 -06:00
Jeff Carr 572a5f37a6 fixes for new gitpb 2024-12-17 07:03:27 -06:00
Jeff Carr 3300be8371 get, list, and send patch sets() 2024-12-14 14:08:16 -06:00
Jeff Carr 019d2961e5 test getting patch sets 2024-12-14 13:12:23 -06:00
Jeff Carr 797edb1d5c more code cleanups 2024-12-14 11:27:54 -06:00
Jeff Carr dead6fe01f new args. use forgepb for versions and dates 2024-12-14 10:47:08 -06:00
Jeff Carr 0775662416 use strings.Fields
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-12-14 09:34:16 -06:00
Jeff Carr 014c9d5e3a remove old git.wit.org references 2024-11-17 06:26:01 -06:00
Jeff Carr 47d10c231f fix build 2024-11-16 00:07:41 -06:00
Jeff Carr 1579e18f69 don't dump repomap anymore 2024-11-14 21:47:34 -06:00
Jeff Carr 305f4d3e41 the traditional name
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-07 12:49:53 -06:00
Jeff Carr e591cdd685 read the footer.html from /etc
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-06 17:10:00 -06:00
Jeff Carr 316f169bc0 make a footer file
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-06 16:51:29 -06:00
Jeff Carr 9242d7a35f cleanup packaging
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-06 16:44:48 -06:00
Jeff Carr 507a8117e1 better notes
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-06 14:50:43 -06:00
Jeff Carr 28e0f09a27 better docs
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-06 14:31:44 -06:00
Jeff Carr 99c773b65b this is overkill
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-06 14:23:21 -06:00
Jeff Carr 6e4c5102c4 more notes
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-06 14:18:25 -06:00
Jeff Carr 6ed4a6924c add notes for mirrors.wit.com
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-03 04:09:46 -06:00
Jeff Carr 50d4acb9c1 ready to be switched to protobuf
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-03 03:07:44 -06:00
Jeff Carr f85d3226e0 I never remember this syntax
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-10-11 17:19:49 -05:00
Jeff Carr d827c398f0 try to rename as gowebd
put the HTML assets raw in the binary also
	I'm how old and still committed a binary. squashed

Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-10-11 17:15:57 -05:00
Jeff Carr c6be85e92f put the Makefile in the debian package
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-10-08 11:34:50 -05:00
Jeff Carr 1f00dfb03e misc
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-10-08 11:32:37 -05:00
Jeff Carr 892b4cc2a8 fix 'make restart'
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-10-08 11:30:31 -05:00
Jeff Carr ded9d338cc attempt a new debian package build
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-10-08 11:23:44 -05:00
Jeff Carr 2b1eed1409 attempt debian postinst script
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-10-08 11:17:37 -05:00
Jeff Carr b283823ffe daemon starts
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-10-08 10:53:57 -05:00
Jeff Carr fface98131 files for making packages
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-10-06 22:01:18 -05:00
Jeff Carr 99f38da618 add powerpaneld
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-10-06 16:34:16 -05:00
Jeff Carr fa6dce4c56 add /uptime to return "OK" for monitoring
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-09-09 10:25:03 -05:00
Jeff Carr 8d12780c4e add go-clone
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-03-07 19:43:00 -06:00
Jeff Carr 0fec5f03a8 ignore files/ left over from dpkg 2024-03-01 07:45:25 -06:00
Jeff Carr 0ef6c32701 add fyne toolkit
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-29 09:30:56 -06:00
Jeff Carr 5cf2867741 rename to forge, rename to resources
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-26 21:48:51 -06:00
Jeff Carr 89610b4a7b rename files to not collide with go-deb 2024-02-23 14:23:41 -06:00
Jeff Carr f0e4214d46 add repolist
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-18 18:52:58 -06:00
Jeff Carr 6661761128 list updates
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-14 15:16:15 -06:00
Jeff Carr 355234774d regisister()
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-13 16:14:22 -06:00
Jeff Carr 270a086963 added link to a demo video
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-13 15:34:12 -06:00
Jeff Carr ebeea1464e reorg the repo list
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-13 08:41:49 -06:00
Jeff Carr 6127ce156f add svg, new repos
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-11 19:26:44 -06:00
Jeff Carr 24c2b897f0 add args
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-10 16:35:30 -06:00
Jeff Carr e8c7e33bfd cosmetics
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-10 08:06:20 -06:00
Jeff Carr 459350eaa1 prune packages without a desc
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-10 07:46:25 -06:00
Jeff Carr 51a8d8d7d2 add package descriptions
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-10 07:34:58 -06:00
28 changed files with 593 additions and 595 deletions

2
.gitignore vendored
View File

@ -3,3 +3,5 @@ go.mod
go.sum go.sum
go.wit.com go.wit.com
gowebd
files/

4
Caddyfile.go.wit.com Normal file
View File

@ -0,0 +1,4 @@
go.wit.com {
encode zstd gzip
reverse_proxy localhost:3000
}

View File

@ -1,15 +1,75 @@
all: .PHONY: build
echo "build it!"
# GO111MODULE=off go get -u -v . VERSION = $(shell git describe --tags)
GO111MODULE=off go build -v -x BUILDTIME = $(shell date +%Y.%m.%d)
su -c ./go.wit.com
# su -c "setcap 'cap_net_bind_service=+ep' go.wit.com" all: build
@echo "make build # build"
@echo "make clean # clean build files"
@echo "make run # build and run on port 2233"
@echo "make debian # will build a debian package"
@echo ""
@echo "make restart # restart the daemon"
@echo "make enable # enable daemon on boot"
@echo "make log # watch the daemon log"
build: goimports
GO111MODULE=off go build \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
verbose:
GO111MODULE=off go build -v -x \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
install:
GO111MODULE=off go install \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
prod: build
make stop
cp gowebd /usr/bin/gowebd
# allow the binary to open ports below 1024
setcap 'cap_net_bind_service=+ep' /usr/bin/gowebd
make start
make log
log:
@#systemctl status gowebd.service
journalctl -f -xeu gowebd.service
enable:
systemctl enable gowebd.service
restart:
systemctl stop gowebd.service
systemctl start gowebd.service
start:
systemctl start gowebd.service
stop:
systemctl stop gowebd.service
run: build
./gowebd --port 2233 --repomap resources/repomap --hostname test.wit.com
# setcap 'cap_net_bind_service=+ep' gowebd # allow the binary to open ports below 1024
goimports: goimports:
reset
goimports -w *.go goimports -w *.go
redomod: clean:
rm -f go.* rm -f go.*
GO111MODULE= go mod init rm -f go.wit.com
GO111MODULE= go mod tidy rm -f gowebd
go-mod-clean purge
# makes a .deb package
debian:
rm ~/incoming/gowebd*.deb
go-deb --no-gui --keep-files --repo go.wit.com/apps/gowebd
squash-the-last-3-commits-together:
git rebase -i HEAD~3
git fsck
git prune

3
README Normal file
View File

@ -0,0 +1,3 @@
makes the website go.wit.com
TODO: make it generic so it can use different DNS names

27
argv.go Normal file
View File

@ -0,0 +1,27 @@
package main
/*
this parses the command line arguements
this enables command line options from other packages like 'gui' and 'log'
*/
import (
"go.wit.com/dev/alexflint/arg"
)
var argv args
type args struct {
ListRepos bool `arg:"--list-repos" help:"list all repositories"`
Port int `arg:"--port" default:"2520" help:"port to run on"`
RepoMap string `arg:"--repomap" default:"/etc/gowebd/repomap" help:"repomap file"`
Hostname string `arg:"--hostname" default:"go.wit.com" help:"hostname to use"`
}
func (args) Version() string {
return "gowebd " + VERSION + " Built on " + BUILDTIME
}
func init() {
arg.MustParse(&argv)
}

16
build Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash -x
# this is the systemd control file
mkdir -p files/lib/systemd/system/
cp gowebd.service files/lib/systemd/system/
# caddy file. propose this as the dir structure caddy should use
mkdir -p files/etc/gowebd/
cp Caddyfile.go.wit.com files/etc/gowebd/
cp resources/Makefile files/etc/gowebd/
# share dir
mkdir -p files/usr/share/gowebd/
cp Makefile files/usr/share/gowebd/
cp -a resources/repomap files/usr/share/gowebd/repomap
cp -a resources files/usr/share/gowebd/

11
control Normal file
View File

@ -0,0 +1,11 @@
Source: gowebd
Build-Depends: golang
Package: gowebd
Maintainer: Jeff Carr <jcarr@wit.com>
Architecture: amd64
Depends: caddy
URL: https://go.wit.com/apps/go.wit.com
Description: the go.wit.com website integration with pkg.go.dev
generates a simple website for integration with golang's
packaging system at http://pkg.go.dev/
TODO: generalize this so other people can use it

View File

@ -4,12 +4,13 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"os"
"time" "time"
"go.wit.com/log" "go.wit.com/log"
) )
func dumpClient(r *http.Request) { func dumpClient(accessf, clientf *os.File, r *http.Request) {
var host, url, proto, addr, agent string var host, url, proto, addr, agent string
host = r.Host host = r.Host
@ -68,3 +69,80 @@ func dumpClient(r *http.Request) {
} }
} }
} }
func registerClient(f *os.File, r *http.Request) bool {
var host, url, proto, addr, agent string
var giturl, gopath string
host = r.Host
url = r.URL.String()
proto = r.Proto
addr = r.RemoteAddr
agent = r.UserAgent()
log.Warn(host, proto, addr, url, agent)
fmt.Fprintln(f, time.Now(), host, proto, addr, url, agent)
// return
fmt.Fprintln(f)
fmt.Fprintln(f, time.Now())
// Basic request information
fmt.Fprintln(f, "Method:", r.Method)
fmt.Fprintln(f, "URL:", r.URL)
fmt.Fprintln(f, "Protocol:", r.Proto)
fmt.Fprintln(f, "Host:", r.Host)
fmt.Fprintln(f, "Remote Address:", r.RemoteAddr)
// Headers
fmt.Fprintln(f, "Headers:")
for name, values := range r.Header {
for _, value := range values {
fmt.Fprintln(f, "Headers:", name, value)
if name == "Giturl" {
giturl = value
}
if name == "Gopath" {
gopath = value
}
}
}
// Query parameters
fmt.Fprintln(f, "Query Parameters:")
for param, values := range r.URL.Query() {
for _, value := range values {
fmt.Fprintln(f, "Query:", param, value)
}
}
// User-Agent
fmt.Fprintln(f, "User-Agent:", r.UserAgent())
// Content Length
fmt.Fprintln(f, "Content Length:", r.ContentLength)
// Cookies
fmt.Fprintln(f, "Cookies:")
for _, cookie := range r.Cookies() {
fmt.Fprintln(f, cookie.Name, cookie.Value)
}
// Request Body (if applicable)
if r.Body != nil {
body, err := ioutil.ReadAll(r.Body)
if err == nil {
fmt.Fprintln(f, "Body:", string(body))
}
}
fmt.Fprintln(f, "gopath =", gopath, "giturl =", giturl)
if gopath == "" {
return false
}
if giturl == "" {
return false
}
fmt.Fprintln(f, "Sent back OK")
return true
}

18
exit.go Normal file
View File

@ -0,0 +1,18 @@
package main
import (
"os"
"go.wit.com/log"
)
func okExit(thing string) {
log.Info(thing, "ok")
// log.Info("Finished go-clean on", check.GetGoPath(), "ok")
os.Exit(0)
}
func badExit(err error) {
log.Info("go-gui-toolkits failed: ", err)
os.Exit(-1)
}

View File

@ -1,200 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="skeleton.v2.css" />
<style>
#footer {
position: fixed;
padding: 1% 0% 1% 0%; /* top left bottom right */
bottom: 0;
width: 100%;
/* Height of the footer*/
height: 40px;
background: lightgrey;
}
</style>
</head>
</html>
<body>
<div class="container">
<div class="row">
<table class="u-full-width">
<thead>
<tr>
<th>Package</th>
<th>go get</th>
<th>Authoritative sources (IPv6 only)</th>
<th>github mirror</th>
<th>Documentation</th>
</tr>
</thead>
<tbody>
<tr> <td><h5>log/ (needed for the gui)</h5></td> <td></td> <td></td> <td></td> <td></td> </tr>
<tr>
<td>log</td>
<td> <a href="//go.wit.com/log">go.wit.com/log</a></td>
<td> <a href="//git.wit.org/wit/log">git.wit.org/wit/log</a></td>
<td> <a href="//github.com/wit-go/log">github.com/wit-go/log</a></td>
<td> <a href="//pkg.go.dev/go.wit.com/log"> <img src="goReference.svg" alt="Go Reference" /> </a> </td>
</tr>
<tr> <td></td> <td></td> <td></td> <td></td> <td></td> </tr>
<tr> <td><h5>gui/ packages</h5></td> <td></td> <td></td> <td></td> <td></td> </tr>
<tr>
<td>gui/gui</td>
<td> <a href="//go.wit.com/gui/gui">go.wit.com/gui/gui</a></td>
<td> <a href="//git.wit.org/gui/gui">git.wit.org/gui/gui</a></td>
<td> <a href="//github.com/wit-go/gui">github.com/wit-go/gui</a></td>
<td> <a href="//pkg.go.dev/go.wit.com/gui/gui"> <img src="goReference.svg" alt="Go Reference" /> </a> </td>
</tr>
<tr>
<td>gui/widget</td>
<td> <a href="//go.wit.com/gui/widget">go.wit.com/gui/widget</a></td>
<td> <a href="//git.wit.org/gui/widget">git.wit.org/gui/widget</a></td>
<td> <a href="//github.com/wit-go/widget">github.com/wit-go/widget</a></td>
<td> <a href="//pkg.go.dev/go.wit.com/gui/widget"> <img src="goReference.svg" alt="Go Reference" /> </a> </td>
</tr>
<tr>
<td>gui/gadgets</td>
<td> <a href="//go.wit.com/gui/gadgets">go.wit.com/gui/gadgets</a></td>
<td> <a href="//git.wit.org/gui/gadgets">git.wit.org/gui/gadgets</a></td>
<td> <a href="//github.com/wit-go/gadgets">github.com/wit-go/gadgets</a></td>
<td> <a href="//pkg.go.dev/go.wit.com/gui/gadgets"> <img src="goReference.svg" alt="Go Reference" /> </a> </td>
</tr>
<tr>
<td>gui/toolkits</td>
<td> <a href="//go.wit.com/gui/toolkits">go.wit.com/gui/toolkits</a></td>
<td> <a href="//git.wit.org/gui/toolkits">git.wit.org/gui/toolkits</a></td>
<td> <a href="//github.com/wit-go/toolkits">github.com/wit-go/toolkits</a></td>
<td> <a href="//pkg.go.dev/go.wit.com/gui/toolkits"> <img src="goReference.svg" alt="Go Reference" /> </a> </td>
</tr>
<tr>
<td>gui/debugger</td>
<td> <a href="//go.wit.com/gui/debugger">go.wit.com/gui/debugger</a></td>
<td> <a href="//git.wit.org/gui/debugger">git.wit.org/gui/debugger</a></td>
<td> <a href="//github.com/wit-go/debugger">github.com/wit-go/debugger</a></td>
<td> <a href="//pkg.go.dev/go.wit.com/gui/debugger"> <img src="goReference.svg" alt="Go Reference" /> </a> </td>
</tr>
<tr>
<td>gui/examples</td>
<td> <a href="//go.wit.com/gui/examples">go.wit.com/gui/examples</a></td>
<td> <a href="//git.wit.org/gui/examples">git.wit.org/gui/examples</a></td>
<td> <a href="//github.com/wit-go/examples">github.com/wit-go/examples</a></td>
<td> </td>
</tr>
<tr>
<td>gui/digitalocean</td>
<td> <a href="//go.wit.com/gui/digitalocean">go.wit.com/gui/digitalocean</a></td>
<td> <a href="//git.wit.org/gui/digitalocean">git.wit.org/gui/digitalocean</a></td>
<td> </td>
<td> <a href="//pkg.go.dev/go.wit.com/gui/digitalocean"> <img src="goReference.svg" alt="Go Reference" /> </a> </td>
</tr>
<tr>
<td>gui/cloudflare</td>
<td> <a href="//go.wit.com/gui/cloudflare">go.wit.com/gui/cloudflare</a></td>
<td> <a href="//git.wit.org/gui/cloudflare">git.wit.org/gui/cloudflare</a></td>
<td> </td>
<td> <a href="//pkg.go.dev/go.wit.com/gui/cloudflare"> <img src="goReference.svg" alt="Go Reference" /> </a> </td>
</tr>
<tr> <td></td> <td></td> <td></td> <td></td> <td></td> </tr>
<tr> <td><h5>Applications</h5></td> <td></td> <td></td> <td></td> <td></td> </tr>
<tr>
<td>control-panel-dns</td>
<td> <a href="//go.wit.com/apps/control-panel-dns">go.wit.com/apps/control-panel-dns</a></td>
<td> <a href="//git.wit.org/jcarr/control-panel-dns">git.wit.org/jcarr/control-panel-dns</a></td>
<td></td>
<td> <a href="//pkg.go.dev/go.wit.com/apps/control-panels-dns"> <img src="goReference.svg" alt="Go Reference" /> </a> </td>
</tr>
<tr>
<td>control-panel-digitalocean</td>
<td> <a href="//go.wit.com/apps/control-panel-digitalocean">go.wit.com/apps/control-panel-digitalocean</a></td>
<td> <a href="//git.wit.org/wit/control-panel-digitalocean">git.wit.org/wit/control-panel-digitalocean</a></td>
<td></td>
<td> <a href="//pkg.go.dev/go.wit.com/apps/control-panel-digitalocean"> <img src="goReference.svg" alt="Go Reference" /> </a> </td>
</tr>
<tr>
<td>control-panel-cloudflare</td>
<td> <a href="//go.wit.com/apps/control-panel-cloudflare">go.wit.com/apps/control-panel-cloudflare</a></td>
<td> <a href="//git.wit.org/wit/control-panel-cloudflare">git.wit.org/wit/control-panel-cloudflare</a></td>
<td></td>
<td> <a href="//pkg.go.dev/go.wit.com/control-panels/cloudflare"> <img src="goReference.svg" alt="Go Reference" /> </a> </td>
</tr>
<!--
<tr>
<td>control-panel-cloudflare</td>
<td> <a href="//go.wit.com/control-panel-cloudflare">go.wit.com/control-panel-cloudflare</a></td>
<td> <a href="//git.wit.org/wit/control-panel-cloudflare">git.wit.org/wit/control-panel-cloudflare</a></td>
<td> <a href="//github.com/wit-go/control-panel-cloudflare">github.com/wit-go/control-panel-cloudflare</a></td>
<td> <a href="//pkg.go.dev/go.wit.com/control-panel-cloudflare"> <img src="goReference.svg" alt="Go Reference" /> </a> </td>
</tr>
-->
<tr> <td></td> <td></td> <td></td> <td></td> <td></td> </tr>
<tr> <td><h5>Support packages</h5></td> <td></td> <td></td> <td></td> <td></td> </tr>
<!--
<tr>
<td>go-arg</td>
<td> <a href="//go.wit.com/arg">go.wit.com/arg</a></td>
<td> <a href="//git.wit.org/gui/arg">git.wit.org/gui/arg</a></td>
<td> <a href="//github.com/wit-go/shell">github.com/alexflint/go-arg</a></td>
<td> <a href="//pkg.go.dev/go.wit.com/shell"> <img src="goReference.svg" alt="Go Reference" /> </a> </td>
</tr>
-->
<tr>
<td>arg</td>
<td> <a href="//go.wit.com/arg">go.wit.com/arg</a></td>
<td> <a href="//git.wit.org/wit/arg">git.wit.org/wit/arg</a></td>
<td> <a href="//github.com/wit-go/go-arg">github.com/wit-go/go-arg</a></td>
<td> <a href="//pkg.go.dev/go.wit.com/arg"> <img src="goReference.svg" alt="Go Reference" /> </a> </td>
</tr>
<tr>
<td>spew</td>
<td> <a href="//go.wit.com/spew">go.wit.com/spew</a></td>
<td> <a href="//git.wit.org/wit/spew">git.wit.org/wit/spew</a></td>
<td> <a href="//github.com/wit-go/spew">github.com/wit-go/spew</a></td>
<td> <a href="//pkg.go.dev/go.wit.com/spew"> <img src="goReference.svg" alt="Go Reference" /> </a> </td>
</tr>
<tr>
<td>dnssec</td>
<td> <a href="//go.wit.com/dnssec">go.wit.com/dnssec</a></td>
<td> <a href="//git.wit.org/wit/dnssec">git.wit.org/wit/dnssec</a></td>
<td> <a href="//github.com/wit-go/dnssec">github.com/wit-go/dnssec</a></td>
<td> <a href="//pkg.go.dev/go.wit.com/dnssec"> <img src="goReference.svg" alt="Go Reference" /> </a> </td>
</tr>
<tr>
<td>shell</td>
<td> <a href="//go.wit.com/shell">go.wit.com/shell</a></td>
<td> <a href="//git.wit.org/wit/shell">git.wit.org/wit/shell</a></td>
<td> <a href="//github.com/wit-go/shell">github.com/wit-go/shell</a></td>
<td> <a href="//pkg.go.dev/go.wit.com/shell"> <img src="goReference.svg" alt="Go Reference" /> </a> </td>
</tr>
<!--
<tr>
<td></td>
<td> <a href=""></a> </td>
<td> <a href=""> <img src="goReference.svg" alt="Go Reference" /> </a> </td>
</tr>
-->
</tbody>
</table>
</div>
</div>
<!--
<center>
<div id="footer">
simple go git repo list like <a href=http://go.uber.org/>go.uber.org</a><p>
</div>
</center>
-->
</body>
</html>

View File

@ -1,48 +0,0 @@
# log/ (needed for the gui)
go.wit.com/log git.wit.org/wit/log
# gui core packages
go.wit.com/widget git.wit.org/gui/widget
go.wit.com/gui git.wit.org/gui/gui
# gui toolkit packages
go.wit.com/toolkits/tree git.wit.org/toolkits/tree
go.wit.com/toolkits/nocui git.wit.org/toolkits/nocui
go.wit.com/toolkits/gocui git.wit.org/toolkits/gocui
go.wit.com/toolkits/andlabs git.wit.org/toolkits/andlabs
go.wit.com/toolkits/debian git.wit.org/toolkits/debian
# gui libraries
go.wit.com/lib/gadgets git.wit.org/gui/gadgets
go.wit.com/lib/debugger git.wit.org/gui/debugger
go.wit.com/lib/gui/repostatus git.wit.org/jcarr/repostatus
go.wit.com/lib/gui/hostname git.wit.org/jcarr/hostname
go.wit.com/lib/gui/linuxstatus git.wit.org/jcarr/hostname
go.wit.com/lib/gui/logsettings git.wit.org/jcarr/logsettings
go.wit.com/lib/gui/digitalocean git.wit.org/gui/digitalocean
go.wit.com/lib/gui/cloudflare git.wit.org/gui/cloudflare
go.wit.com/lib/gui/shell git.wit.org/wit/shell
go.wit.com/lib/protobuf/wit git.wit.org/wit/witProtobuf
# Applications
go.wit.com/apps/helloworld git.wit.org/gui/helloworld
go.wit.com/apps/basicwindow git.wit.org/jcarr/basicwindow
go.wit.com/apps/gadgetwindow git.wit.org/jcarr/gadgetwindow
go.wit.com/apps/autotypist git.wit.org/jcarr/autotypist
go.wit.com/apps/guireleaser git.wit.org/jcarr/guireleaser
go.wit.com/apps/control-panel-dns git.wit.org/jcarr/control-panel-dns
go.wit.com/apps/control-panel-digitalocean git.wit.org/wit/control-panel-digitalocean
go.wit.com/apps/control-panel-cloudflare git.wit.org/wit/control-panel-cloudflare
go.wit.com/apps/control-panel-vpn git.wit.org/jcarr/control-panel-vpn
go.wit.com/apps/go.wit.com git.wit.org/jcarr/go.wit.com
# Support packages
go.wit.com/dev/alexflint/arg git.wit.org/jcarr/go-arg
go.wit.com/dev/alexflint/scalar git.wit.org/jcarr/go-scalar
go.wit.com/dev/andlabs/ui git.wit.org/interesting/andlabs-ui
go.wit.com/dev/andlabs/libui git.wit.org/interesting/libui
go.wit.com/dev/davecgh/spew git.wit.org/jcarr/go-spew

View File

@ -1,11 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta name="go-import" content="go.wit.com/gui/gui git https://git.wit.org/gui/gui">
<meta name="go-source" content="go.wit.com/gui/gui https://git.wit.org/gui/gui https://git.wit.org/gui/tree/master{/dir} https://git.wit.org/gui/gui/tree/master{/dir}/{file}#L{line}">
<meta http-equiv="refresh" content="0; url=https://git.wit.org/gui/gui">
</head>
<body>
Nothing to see here. Please <a href="https://git.wit.org/gui/gui">move along</a>.
</body>
</html>

13
gowebd.service Normal file
View File

@ -0,0 +1,13 @@
[Unit]
Description=gowebd
[Service]
User=root
Type=simple
ExecStart=/usr/bin/gowebd
ExecStop=killall gowebd
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target

148
http.go Normal file
View File

@ -0,0 +1,148 @@
package main
import (
"fmt"
"io/ioutil"
"net/http"
"os"
"path/filepath"
"strings"
"go.wit.com/log"
)
// remove '?' part and trailing '/'
func cleanURL(url string) string {
url = "/" + strings.Trim(url, "/")
return url
}
func okHandler(w http.ResponseWriter, r *http.Request) {
msg, err := ioutil.ReadAll(r.Body) // Read the body as []byte
if err != nil {
log.Info("ioutil.ReadAll() error =", err)
return
}
// fmt.Fprintln(w, "ioutil.ReadAll() msg =", len(msg))
// dumpClient(accessf, clientf, r)
var route string
// tmp = r.URL.String()
route = cleanURL(r.URL.Path)
parts := strings.Split(route, "?")
log.Info("client sent url =", route, parts)
requrl := parts[0]
url, repourl := findkey(requrl)
log.Warn("gowebd URL =", url, "REPO URL =", repourl, "REQUEST URL =", requrl, "msg =", len(msg))
if repourl != "" {
repoHTML(w, url, repourl)
return
}
if route == "/" {
indexHeader(w)
indexBodyStart(w)
indexBodyScanConfig(w)
indexDivEnd(w)
pfile, err := os.ReadFile(FOOTER)
if err == nil {
fmt.Fprint(w, string(pfile))
} else {
log.Warn(err, "no footer file found in", FOOTER)
log.Warn("falling back to the resources/footer.html")
writeFile(w, "footer.html")
}
indexBodyEnd(w)
return
}
if route == "/install.sh" {
writeFile(w, "install.sh")
return
}
if route == "/me" {
j, err := dumpJsonClient(r)
if err != nil {
fmt.Fprintln(w, "BAD ZOOT")
return
}
fmt.Fprintln(w, j)
return
}
if route == "/register" {
fname := filepath.Join(LIBDIR, "regfile.log")
regfile, _ := os.OpenFile(fname, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if registerClient(regfile, r) {
fmt.Fprintln(w, "OK")
} else {
fmt.Fprintln(w, "FAILED")
}
return
}
if route == "/lookup" {
w.Header().Set("Content-Type", "text")
fmt.Fprintf(w, "go.wit.com/apps/utils/gowebd Version: %s\n", argv.Version())
fmt.Fprintf(w, "\n")
all := forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
fmt.Fprintf(w, "Namespace=%s FullPath=%s %s\n", repo.Namespace, repo.FullPath)
}
return
}
if route == "/goReference.svg" {
writeFile(w, "goReference.svg")
return
}
if route == "/skeleton.v2.css" {
writeFile(w, "skeleton.v2.css")
return
}
if route == "/favicon.ico" {
writeFile(w, "ipv6.png")
return
}
// used for uptime monitor checking
if route == "/uptime" {
writeFile(w, "uptime.html")
return
}
log.Warn("BAD URL =", url, "REPO URL =", repourl)
badurl(w, r.URL.String())
}
func writeFile(w http.ResponseWriter, filename string) {
// fmt.Fprintln(w, "GOT TEST?")
fullname := "resources/" + filename
pfile, err := resources.ReadFile(fullname)
if err != nil {
log.Println("ERROR:", err)
// w.Write(pfile)
return
}
var repohtml string
repohtml = string(pfile)
if filename == "goReference.svg" {
w.Header().Set("Content-Type", "image/svg+xml")
}
fmt.Fprintln(w, repohtml)
log.Println("writeFile() found internal file:", filename)
}
func badurl(w http.ResponseWriter, badurl string) {
fmt.Fprintln(w, "<!DOCTYPE html>")
fmt.Fprintln(w, "<html>")
fmt.Fprintln(w, " <head>")
fmt.Fprintln(w, " <meta http-equiv=\"refresh\" content=\"3; url=https://"+HOSTNAME+"/\">")
fmt.Fprintln(w, " </head>")
fmt.Fprintln(w, " <body>")
fmt.Fprintln(w, " IPv4 IS NOT SUPPORTED<br>")
fmt.Fprintln(w, " MANY OF THESE REPOS REQUIRE IPv6.<br>")
fmt.Fprintln(w, " <br>")
fmt.Fprintln(w, " bad url", badurl, "<a href=\"https://go.wit.com/\">redirecting</a>")
fmt.Fprintln(w, " </body>")
fmt.Fprintln(w, "</html>")
}

View File

@ -3,11 +3,7 @@ package main
import ( import (
"fmt" "fmt"
"net/http" "net/http"
"strconv"
"strings" "strings"
"time"
"go.wit.com/log"
) )
func indexHeader(w http.ResponseWriter) { func indexHeader(w http.ResponseWriter) {
@ -38,14 +34,14 @@ func indexBodyStart(w http.ResponseWriter) {
fmt.Fprintln(w, " <table class=\"u-full-width\">") fmt.Fprintln(w, " <table class=\"u-full-width\">")
// fmt.Fprintln(w, " <thead>") // fmt.Fprintln(w, " <thead>")
fmt.Fprintln(w, " <tr>") fmt.Fprintln(w, " <tr>")
fmt.Fprintln(w, " <th>Package</th>") fmt.Fprintln(w, " <th>Package (IPv6 only)</th>")
fmt.Fprintln(w, " <th>Version</th>")
fmt.Fprintln(w, " <th>Age</th>")
fmt.Fprintln(w, " <th>Dev Version</th>")
fmt.Fprintln(w, " <th>go get</th>")
fmt.Fprintln(w, " <th>Authoritative sources (IPv6 only)</th>")
fmt.Fprintln(w, " <th></th>")
fmt.Fprintln(w, " <th>Documentation</th>") fmt.Fprintln(w, " <th>Documentation</th>")
fmt.Fprintln(w, " <th>Version</th>")
fmt.Fprintln(w, " <th>Dev Version</th>")
fmt.Fprintln(w, " <th>Age</th>")
fmt.Fprintln(w, " <th>Description</th>")
// fmt.Fprintln(w, " <th>Authoritative sources (IPv6 only)</th>")
// fmt.Fprintln(w, " <th></th>")
fmt.Fprintln(w, " </tr>") fmt.Fprintln(w, " </tr>")
// fmt.Fprintln(w, " </thead>") // fmt.Fprintln(w, " </thead>")
fmt.Fprintln(w, " <tbody>") fmt.Fprintln(w, " <tbody>")
@ -58,7 +54,7 @@ func insertHTMLnote(w http.ResponseWriter, i int, parts []string) {
} }
func indexBodyScanConfig(w http.ResponseWriter) { func indexBodyScanConfig(w http.ResponseWriter) {
log.Info("indexBodyScanConfig() START") // log.Info("indexBodyScanConfig() START")
for i, line := range configfile { for i, line := range configfile {
// log.Info("config file line:", i, line) // log.Info("config file line:", i, line)
fields := strings.Fields(line) fields := strings.Fields(line)
@ -71,62 +67,51 @@ func indexBodyScanConfig(w http.ResponseWriter) {
continue continue
} }
if len(fields) == 2 { if len(fields) == 2 {
log.Info("short file line:", i, line) // log.Info("short file line:", i, line)
gourl := fields[0] gourl := fields[0]
giturl := fields[1] giturl := fields[1]
indexBodyRepo(w, gourl, giturl, "") indexBodyRepo(w, gourl, giturl, "")
continue continue
} }
log.Info("config file line:", i, line) if len(fields) > 2 {
// log.Info("short file line:", i, line)
gourl := fields[0]
giturl := fields[1]
desc := strings.Join(fields[2:], " ")
desc = strings.TrimSpace(desc)
indexBodyRepo(w, gourl, giturl, desc)
continue
} }
log.Info("indexBodyScanConfig() END") // log.Info("config file line:", i, line)
}
// log.Info("indexBodyScanConfig() END")
} }
func indexBodyRepo(w http.ResponseWriter, gourl string, giturl string, github string) { func indexBodyRepo(w http.ResponseWriter, gourl string, giturl string, desc string) {
// skip displaying packages without a desc
if desc == "" {
return
}
// fmt.Fprintln(w, " <tr> <td><h5>log/ (needed for the gui)</h5></td> <td></td> <td></td> <td></td> <td></td> </tr>") // fmt.Fprintln(w, " <tr> <td><h5>log/ (needed for the gui)</h5></td> <td></td> <td></td> <td></td> <td></td> </tr>")
fmt.Fprintln(w, " <tr>") fmt.Fprintln(w, " <tr>")
fmt.Fprintln(w, " <td>"+gourl+"</td>") // fmt.Fprintln(w, " <td>"+gourl+"</td>")
for i, s := range versionMap { fmt.Fprintln(w, " <td> <a href=\"//"+gourl+"\">"+gourl+"</a></td>")
log.Println("found i =", i, "with", "s =", s) fmt.Fprintln(w, " <td> <a href=\"//pkg.go.dev/"+gourl+"\"> <img src=\"goReference.svg\" alt=\"pkg.go.dev\" /> </a> </td>")
} var vtime, version, dver string
var vtime, version string
gourl = strings.TrimSpace(gourl) gourl = strings.TrimSpace(gourl)
tmp, _ := versionMap[gourl] if repo, ok := gitMap[gourl]; ok {
parts := strings.Split(tmp, " ") version = repo.GetLastTag()
if len(parts) > 0 { age := repo.NewestAge()
version = parts[0] vtime = formatDuration(age)
} dver = repo.GetDevelVersion()
if len(parts) > 1 {
vtime = parts[1]
}
if vtime != "" {
// Convert the string to an integer
gitTagTimestampInt, _ := strconv.ParseInt(vtime, 10, 64)
// Parse the Unix timestamp into a time.Time object
gitTagDate := time.Unix(gitTagTimestampInt, 0)
// Get the current time
currentTime := time.Now()
// Calculate the duration between the git tag date and the current time
duration := currentTime.Sub(gitTagDate)
vtime = formatDuration(duration)
} }
// log.Info("gopath", gourl, "dur", vtime, "version", version)
fmt.Fprintln(w, " <td>"+version+"</td>") // version fmt.Fprintln(w, " <td>"+version+"</td>") // version
fmt.Fprintln(w, " <td>"+ vtime +"</td>") // dev version fmt.Fprintln(w, " <td>"+dver+"</td>") // dev version
fmt.Fprintln(w, " <td></td>") // dev version fmt.Fprintln(w, " <td>"+vtime+"</td>") // dev version
fmt.Fprintln(w, " <td> <a href=\"//"+gourl+"\">"+gourl+"</a></td>") fmt.Fprintln(w, " <td>"+desc+"</td>")
fmt.Fprintln(w, " <td> <a href=\"//"+gourl+"\">"+giturl+"</a></td>") // fmt.Fprintln(w, " <td> <a href=\"//"+gourl+"\">"+giturl+"</a></td>")
if github == "" {
fmt.Fprintln(w, " <td></td>")
} else {
fmt.Fprintln(w, " <td> <a href=\"//github.com/wit-go/log\">github.com/wit-go/log</a></td>")
}
fmt.Fprintln(w, " <td> <a href=\"//pkg.go.dev/"+gourl+"\"> <img src=\"goReference.svg\" alt=\"pkg.go.dev docs\" /> </a> </td>")
fmt.Fprintln(w, " </tr>") fmt.Fprintln(w, " </tr>")
fmt.Fprintln(w, "") fmt.Fprintln(w, "")
} }

View File

@ -17,8 +17,8 @@ type RequestInfo struct {
Headers map[string][]string `json:"headers"` Headers map[string][]string `json:"headers"`
Cookies map[string]string `json:"cookies"` Cookies map[string]string `json:"cookies"`
QueryParams map[string][]string `json:"queryParams"` QueryParams map[string][]string `json:"queryParams"`
// Add other fields as needed
Body string `json:"body"` Body string `json:"body"`
// Add other fields as needed
} }
// dumpClient returns a string with JSON formatted http.Request information // dumpClient returns a string with JSON formatted http.Request information
@ -68,41 +68,3 @@ func dumpJsonClient(r *http.Request) (string, error) {
return string(formattedJSON), nil return string(formattedJSON), nil
} }
/*
package main
import (
"bytes"
"encoding/json"
"io"
"io/ioutil"
"net/http"
)
type RequestInfo struct {
// ... (other fields)
Body string `json:"body"`
// ... (other fields)
}
func dumpClient(r *http.Request) (string, error) {
// ... (rest of your code to collect other request info)
info := RequestInfo{
// ... (other fields)
Body: string(bodyBytes),
// ... (other fields)
}
// Marshal the struct to a JSON string
jsonString, err := json.Marshal(info)
if err != nil {
return "", err
}
return string(jsonString), nil
}
// ... (rest of your code)
*/

150
main.go
View File

@ -4,141 +4,61 @@ import (
"embed" "embed"
"fmt" "fmt"
"net/http" "net/http"
"os"
"strings"
"time" "time"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log" "go.wit.com/log"
) )
//go:embed files/* // are sent via -ldflags at buildtime
var htmlFiles embed.FS var VERSION string
var BUILDTIME string
var accessf, clientf *os.File //go:embed resources/*
var resources embed.FS
// var accessf, clientf *os.File
var repoMap map[string]string var repoMap map[string]string
var versionMap map[string]string var gitMap map[string]*gitpb.Repo
var configfile []string var configfile []string
var keysSorted []string var keysSorted []string
var forge *forgepb.Forge
// remove '?' part and trailing '/' var HOSTNAME string = "go.wit.com"
func cleanURL(url string) string { var REPOMAP string = "/etc/gowebd/repomap"
url = "/" + strings.Trim(url, "/") var FOOTER string = "/etc/gowebd/footer.html"
return url var LIBDIR string = "/var/lib/gowebd/"
}
func okHandler(w http.ResponseWriter, r *http.Request) {
dumpClient(r)
var tmp string
// tmp = r.URL.String()
tmp = cleanURL(r.URL.Path)
parts := strings.Split(tmp, "?")
log.Info("client sent url =", tmp)
log.Info("parts are:", parts)
requrl := parts[0]
url, repourl := findkey(requrl)
log.Warn("go.wit.com URL =", url, "REPO URL =", repourl, "REQUEST URL =", requrl)
if repourl != "" {
repoHTML(w, url, repourl)
return
}
if tmp == "/" {
indexHeader(w)
indexBodyStart(w)
indexBodyScanConfig(w)
indexDivEnd(w)
indexBodyEnd(w)
return
}
if tmp == "/old" {
findFile(w, "files/index.html")
return
}
if tmp == "/me" {
j, err := dumpJsonClient(r)
if err != nil {
fmt.Fprintln(w, "BAD ZOOT")
return
}
fmt.Fprintln(w, j)
return
}
if tmp == "/update" {
return
}
if tmp == "/list" {
findFile(w, "files/repomap")
return
}
if tmp == "/test" {
findFile(w, "files/test.html")
return
}
if tmp == "/skeleton.v2.css" {
findFile(w, "files/skeleton.v2.css")
return
}
log.Warn("BAD URL =", url, "REPO URL =", repourl)
badurl(w, r.URL.String())
// fmt.Fprintln(w, "BAD", tmp)
}
func findFile(w http.ResponseWriter, filename string) {
// fmt.Fprintln(w, "GOT TEST?")
pfile, err := htmlFiles.ReadFile(filename)
if err != nil {
log.Println("ERROR:", err)
// w.Write(pfile)
return
}
var repohtml string
repohtml = string(pfile)
fmt.Fprintln(w, repohtml)
log.Println("findFile() found internal file:", filename)
// w.Close()
/*
filename = "/tmp/" + name + ".so"
log.Error(err, "write out file here", name, filename, len(pfile))
f, _ := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0600)
f.Close()
*/
}
func main() { func main() {
accessf, _ = os.OpenFile("/home/jcarr/accessclient.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) if argv.RepoMap != "" {
clientf, _ = os.OpenFile("/home/jcarr/httpclient.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) REPOMAP = argv.RepoMap
readconfigfile()
readVersionFile()
for i, s := range versionMap {
log.Println("found i =", i, "with", "s =", s)
} }
log.Println("found log =", versionMap["go.wit.com/log"]) if argv.Hostname != "" {
HOSTNAME = argv.Hostname
}
gitMap = make(map[string]*gitpb.Repo)
repoMap = make(map[string]string)
forge = forgepb.Init()
// parse the repomap file
readRepomap()
// readVersionFile()
http.HandleFunc("/", okHandler) http.HandleFunc("/", okHandler)
go https() // go https() // use caddy instead
err := http.ListenAndServe(":80", nil) p := fmt.Sprintf(":%d", argv.Port)
log.Println("HOSTNAME set to:", HOSTNAME)
log.Println("Running on port", p)
err := http.ListenAndServe(p, nil)
if err != nil { if err != nil {
log.Println("Error starting server:", err) log.Println("Error starting server:", err)
} }
} }
func badurl(w http.ResponseWriter, badurl string) {
fmt.Fprintln(w, "<!DOCTYPE html>")
fmt.Fprintln(w, "<html>")
fmt.Fprintln(w, " <head>")
fmt.Fprintln(w, " <meta http-equiv=\"refresh\" content=\"3; url=https://go.wit.com/\">")
fmt.Fprintln(w, " </head>")
fmt.Fprintln(w, " <body>")
fmt.Fprintln(w, " IPv4 IS NOT SUPPORTED<br>")
fmt.Fprintln(w, " MANY OF THESE REPOS REQUIRE IPv6.<br>")
fmt.Fprintln(w, " <br>")
fmt.Fprintln(w, " bad url", badurl, "<a href=\"https://git.wit.org/\">redirecting</a>")
fmt.Fprintln(w, " </body>")
fmt.Fprintln(w, "</html>")
}
func formatDuration(d time.Duration) string { func formatDuration(d time.Duration) string {
seconds := int(d.Seconds()) % 60 seconds := int(d.Seconds()) % 60
minutes := int(d.Minutes()) % 60 minutes := int(d.Minutes()) % 60

7
postinst Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
set -e
cd /etc/gowebd/
# allow the binary to open ports below 1024
setcap 'cap_net_bind_service=+ep' /usr/bin/gowebd

View File

@ -1,118 +0,0 @@
package main
import (
"bufio"
"fmt"
"net/http"
"os"
"path/filepath"
"sort"
"strings"
"go.wit.com/log"
)
/*
<!DOCTYPE html>
<html>
<head>
<meta name="go-import" content="go.wit.com/gui/gui git https://git.wit.org/gui/gui">
<meta name="go-source" content="go.wit.com/gui/gui https://git.wit.org/gui/gui https://git.wit.org/gui/tree/master{/dir} https://git.wit.org/gui/gui/tree/master{/dir}/{file}#L{line}">
<meta http-equiv="refresh" content="0; url=https://git.wit.org/gui/gui">
</head>
<body>
Nothing to see here. Please <a href="https://git.wit.org/gui/gui">move along</a>.
</body>
</html>
*/
func repoHTML(w http.ResponseWriter, gourl string, realurl string) {
realurl = "https://" + realurl
log.Info("go repo =", gourl, "real url =", realurl)
fmt.Fprintln(w, "<!DOCTYPE html>")
fmt.Fprintln(w, "<html>")
fmt.Fprintln(w, "<head>")
// fmt.Fprintln(w,
fmt.Fprintln(w, "<meta name=\"go-import\" content=\"", gourl, "git", realurl+"\">")
fmt.Fprintln(w, "<meta name=\"go-source\" content=\"", gourl, realurl, realurl+"/tree/master{/dir}", realurl+"tree/master{/dir}/{file}#L{line}", "\"", ">")
fmt.Fprintln(w, "<meta http-equiv=\"refresh\" content=\"0; url="+realurl+"\">")
fmt.Fprintln(w, "</head>")
fmt.Fprintln(w, "<body>")
fmt.Fprintln(w, "Nothing to see here. Please <a href=\""+realurl+"\">move along</a>.\"")
fmt.Fprintln(w, "</body>")
fmt.Fprintln(w, "</html>")
/*
var tmp string
tmp = r.URL.String()
if tmp == "/gui" {
findFile(w)
return
}
fmt.Fprintln(w, "OK")
*/
}
func findkey(url string) (string, string) {
key := "go.wit.com" + url
if repoMap[key] != "" {
return key, repoMap[key]
}
return key, ""
// parts := strings.Split(key, "/")
}
func readconfigfile() {
repoMap = make(map[string]string)
pfile, err := htmlFiles.ReadFile("files/repomap")
if err != nil {
log.Error(err, "missing repomap in the binary")
return
}
configfile = strings.Split(string(pfile), "\n")
for _, line := range configfile {
fields := strings.Fields(line)
if len(fields) < 2 {
continue
}
repo := fields[0]
realurl := fields[1]
repoMap[repo] = realurl
// log.Info("repo =", repo, "real url =", realurl)
}
for repo, _ := range repoMap {
// log.Info("repo =", repo, "real url =", url)
keysSorted = append(keysSorted, repo)
}
log.Info("sorted:")
sort.Strings(keysSorted)
// sort.Reverse(keys)
sort.Sort(sort.Reverse(sort.StringSlice(keysSorted)))
for _, key := range keysSorted {
log.Info("repo =", key, "real url =", repoMap[key])
}
}
func readVersionFile() {
versionMap = make(map[string]string)
file, err := os.Open(filepath.Join(os.Getenv("HOME"), "go.wit.com.versions"))
if err != nil {
return
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
tmp := scanner.Text()
fields := strings.Split(tmp, " ")
if len(fields) < 2 {
continue
}
// log.Println("readVersionFile() fields[0] =", fields[0])
// log.Println("readVersionFile() fields[1:] =", fields[1:])
versionMap[fields[0]] = strings.Join(fields[1:], " ")
}
}

75
repomap.go Normal file
View File

@ -0,0 +1,75 @@
package main
// parses /etc/gowebd/repomap
// this file defines what repositories show up on go.wit.com
import (
"fmt"
"net/http"
"os"
"strings"
"go.wit.com/log"
)
// this makes the "go-source" / "go-import" page
// this redirects the go path "go.wit.com/apps/go-clone" to the git path "gitea.wit.com/wit/go-clone"
func repoHTML(w http.ResponseWriter, gourl string, realurl string) {
realurl = "https://" + realurl
log.Info("go repo =", gourl, "real url =", realurl)
fmt.Fprintln(w, "<!DOCTYPE html>")
fmt.Fprintln(w, "<html>")
fmt.Fprintln(w, "<head>")
// fmt.Fprintln(w,
fmt.Fprintln(w, "<meta name=\"go-import\" content=\"", gourl, "git", realurl+"\">")
fmt.Fprintln(w, "<meta name=\"go-source\" content=\"", gourl, realurl, realurl+"/tree/master{/dir}", realurl+"tree/master{/dir}/{file}#L{line}", "\"", ">")
fmt.Fprintln(w, "<meta http-equiv=\"refresh\" content=\"0; url="+realurl+"\">")
fmt.Fprintln(w, "</head>")
fmt.Fprintln(w, "<body>")
fmt.Fprintln(w, "Redirecting to git repo url. Please <a href=\""+realurl+"\">move along</a>.\"")
fmt.Fprintln(w, "</body>")
fmt.Fprintln(w, "</html>")
}
func findkey(url string) (string, string) {
key := "go.wit.com" + url
if repoMap[key] != "" {
return key, repoMap[key]
}
return key, ""
// parts := strings.Split(key, "/")
}
func readRepomap() {
var pfile []byte
var err error
pfile, err = os.ReadFile(REPOMAP)
if err != nil {
log.Error(err, "no repository map file found in /etc/gowebd/")
log.Error(err, "falling back to the repository map file built into the gowebd binary")
pfile, err = resources.ReadFile("resources/repomap")
if err != nil {
log.Error(err, "missing repomap in the binary")
return
}
}
configfile = strings.Split(string(pfile), "\n")
for _, line := range configfile {
fields := strings.Fields(line)
if len(fields) < 2 {
continue
}
gopath := fields[0]
giturl := fields[1]
repoMap[gopath] = giturl
repo := forge.FindByGoPath(gopath)
if repo != nil {
gitMap[gopath] = repo
} else {
log.Info("repo =", gopath, "real url =", repoMap[gopath], "not found")
}
}
}

19
resources/Makefile Normal file
View File

@ -0,0 +1,19 @@
all:
gowebd --version
@echo "make log # watch gowebd log"
@echo "make restart # restart gowebd"
@echo "make enable # enable gowebd on boot"
@echo "make status # show the systemd status of gowebd"
log:
@journalctl -f -xeu gowebd.service
status:
systemctl status gowebd.service
enable:
systemctl enable gowebd.service
restart:
systemctl stop gowebd.service
systemctl start gowebd.service

3
resources/footer.html Normal file
View File

@ -0,0 +1,3 @@
<br>
your footer here<br>
<br>

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
resources/ipv6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

15
resources/repomap Normal file
View File

@ -0,0 +1,15 @@
# gui core packages
go.wit.com/gui gitea.wit.com/gui/gui The GUI API intended for Control Panels
go.wit.com/widget gitea.wit.com/gui/widget Primitive Definitions for Buttons, Dropdowns, etc.
# Tutorials
go.wit.com/apps/helloworld gitea.wit.com/gui/helloworld A simple Demo
go.wit.com/apps/basicwindow gitea.wit.com/jcarr/basicwindow A bit more of a Demo
go.wit.com/apps/gadgetwindow gitea.wit.com/jcarr/gadgetwindow A more complicated Demo used for debugging the toolkits
# Applications (mirrors.wit.com has .deb packages)
go.wit.com/apps/go-clone gitea.wit.com/gui/go-clone recursively 'git clone' golang packages
go.wit.com/apps/go-deb gitea.wit.com/jcarr/go-deb Turn anything into a .deb package

8
resources/uptime.html Normal file
View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
OK12358
</body>
</html>