diff --git a/Dockerfile b/Dockerfile index baf7e11..5b90ceb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ WORKDIR /work COPY go.mod . COPY . . RUN go mod download -RUN make && strip cenod +RUN make && strip ephemerupd FROM alpine:3.17 LABEL maintainer="Uploads Author " @@ -20,14 +20,14 @@ LABEL maintainer="Uploads Author " RUN install -o 1001 -g 1001 -d /data WORKDIR /app -COPY --from=builder /work/cenod /app/cenod +COPY --from=builder /work/ephemerupd /app/ephemerupd -ENV CENOD_LISTEN=:8080 -ENV CENOD_STORAGEDIR=/data -ENV CENOD_DBFILE=/data/bbolt.db -ENV CENOD_DEBUG=1 +ENV EPHEMERUPD_LISTEN=:8080 +ENV EPHEMERUPD_STORAGEDIR=/data +ENV EPHEMERUPD_DBFILE=/data/bbolt.db +ENV EPHEMERUPD_DEBUG=1 USER 1001:1001 EXPOSE 8080 VOLUME /data -CMD ["/app/cenod"] +CMD ["/app/ephemerupd"] diff --git a/Makefile b/Makefile index a05d2b9..5ab195b 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ COMMIT = $(shell git rev-parse --short=8 HEAD) BUILD = $(shell date +%Y.%m.%d.%H%M%S) VERSION := $(if $(filter $(BRANCH), development),$(version)-$(BRANCH)-$(COMMIT)-$(BUILD),$(version)) HAVE_POD := $(shell pod2text -h 2>/dev/null) -DAEMON := cenod +DAEMON := ephemerupd all: buildlocal buildlocalctl @@ -35,7 +35,7 @@ buildlocalctl: make -C upctl buildlocal: - go build -ldflags "-X 'github.com/tlinden/cenophane/cfg.VERSION=$(VERSION)'" -o $(DAEMON) + go build -ldflags "-X 'github.com/tlinden/ephemerup/cfg.VERSION=$(VERSION)'" -o $(DAEMON) buildimage: clean docker-compose --verbose build @@ -60,15 +60,15 @@ test: singletest: @echo "Call like this: ''make singletest TEST=TestX1 MOD=lib" - go test -run $(TEST) github.com/tlinden/cenophane/$(MOD) + go test -run $(TEST) github.com/tlinden/ephemerup/$(MOD) cover-report: go test ./... -cover -coverprofile=coverage.out go tool cover -html=coverage.out show-versions: buildlocal - @echo "### cenod version:" - @./cenod --version + @echo "### ephemerupd version:" + @./ephemerupd --version @echo @echo "### go module versions:" diff --git a/README.md b/README.md index 62e4bb8..8a1af32 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# Cenophane +# ephemerup Simple standalone file upload server with expiration and commandline client. ## Introduction -**Cenophane** is a simple standalone file server where every uploaded +**ephemerup** is a simple standalone file server where every uploaded file expires sooner or later. The server provides a RESTful API and can be used easily with the commandline client `upctl`. @@ -13,7 +13,7 @@ important enough to keep them around. Think of this szenario: you're working for the network departement and there's a problem with your routing. Tech support asks you to create a network trace and send it to them. But you can't because the trace file is too large and -sensitive to be sent by email. This is where **Cenophane** comes to +sensitive to be sent by email. This is where **ephemerup** comes to the rescue. You upload the file, send the download url to the other party and - @@ -21,11 +21,11 @@ assuming you've utilized the defaults - when they download it, it is being deleted immediately from the server. But you can also set an expire time, say 5 days or something like that. -The download urls generated by **Cenophane** consist of a unique +The download urls generated by **ephemerup** consist of a unique onetime hash, so they are somewhat confident. However, if you're uploading really sensitive data, you better encrypt it. -**Cenophane** also supports something we call an API Context. There +**ephemerup** also supports something we call an API Context. There can be many such API contexts. Each of these has an associated token, which has to be used by legitimate clients to authenticate and authorize. A user can only manage uploads within that context. Think @@ -60,17 +60,17 @@ releases available yet. You'll need a go build environment. Just run There's a `Dockerfile` available for the server so you can build and run it using docker: ``` make buildimage -docker-compose run cenophane +docker-compose run ephemerup ``` Then use the client to test it. ## Server Usage ``` -cenod -h +ephemerupd -h --apikeys strings Api key[s] to allow access -a, --apiprefix string API endpoint path (default "/api") - -n, --appname string App name to say hi as (default "cenod v0.0.1") + -n, --appname string App name to say hi as (default "ephemerupd v0.0.1") -b, --bodylimit int Max allowed upload size in bytes (default 10250000000) -c, --config string custom config file -D, --dbfile string Bold database file to use (default "/tmp/uploads.db") @@ -86,23 +86,23 @@ cenod -h -v, --version Print program version ``` -All flags can be set using environment variables, prefix the flag with `CENOD_` and uppercase it, eg: +All flags can be set using environment variables, prefix the flag with `EPHEMERUPD_` and uppercase it, eg: ``` -CENOD_LISTEN=:8080 +EPHEMERUPD_LISTEN=:8080 ``` In addition it is possible to set api contexts using env vars (otherwise only possible using the config file): ``` -CENOD_CONTEXT_SUPPORT="support:tymag-fycyh-gymof-dysuf-doseb-puxyx" -CENOD_CONTEXT_FOOBAR="foobar:U3VuIE1hciAxOSAxMjoyNTo1NyBQTSBDRVQgMjAyMwo" +EPHEMERUPD_CONTEXT_SUPPORT="support:tymag-fycyh-gymof-dysuf-doseb-puxyx" +EPHEMERUPD_CONTEXT_FOOBAR="foobar:U3VuIE1hciAxOSAxMjoyNTo1NyBQTSBDRVQgMjAyMwo" ``` Configuration can also be done using a config file (searched in the following locations): -- `/etc/cenod.hcl` -- `/usr/local/etc/cenod.hcl` -- `~/.config/cenod/cenod.hcl` -- `~/.cenod` -- `$(pwd)/cenod.hcl` +- `/etc/ephemerupd.hcl` +- `/usr/local/etc/ephemerupd.hcl` +- `~/.config/ephemerupd/ephemerupd.hcl` +- `~/.ephemerupd` +- `$(pwd)/ephemerupd.hcl` Or using the flag `-c`. Sample config file: ``` @@ -131,7 +131,7 @@ super = "root" The server serves the API under the following endpoint: `http://SERVERNAME[:PORT]/api/v1` where SERVERNAME[:PORT] is the argument to the `-l` commandline argument or the config option -`listen` or the environment variable `CENOD_LISTEN`. +`listen` or the environment variable `EPHEMERUPD_LISTEN`. By default the server listens on any interface ip4 and ipv6 on TCP port 8080. You can specify a server name or an ipaddress and a @@ -181,7 +181,7 @@ endpoint = "http://localhost:8080/api/v1" apikey = "970b391f22f515d96b3e9b86a2c62c627968828e47b356994d2e583188b4190a" ``` -The `endpoint` is the **Cenophane** server running somewhere and the +The `endpoint` is the **ephemerup** server running somewhere and the `apikey` is the token you got from the server operator.. diff --git a/api/auth.go b/api/auth.go index 0f57145..4cc40eb 100644 --- a/api/auth.go +++ b/api/auth.go @@ -23,7 +23,7 @@ import ( "errors" "github.com/gofiber/fiber/v2" "github.com/gofiber/keyauth/v2" - "github.com/tlinden/cenophane/cfg" + "github.com/tlinden/ephemerup/cfg" "regexp" ) diff --git a/api/cleaner.go b/api/cleaner.go index f69b779..1f49544 100644 --- a/api/cleaner.go +++ b/api/cleaner.go @@ -21,8 +21,8 @@ import ( "fmt" //"github.com/alecthomas/repr" "encoding/json" - "github.com/tlinden/cenophane/cfg" - "github.com/tlinden/cenophane/common" + "github.com/tlinden/ephemerup/cfg" + "github.com/tlinden/ephemerup/common" bolt "go.etcd.io/bbolt" "path/filepath" "time" diff --git a/api/db.go b/api/db.go index 24613a1..efe5cd8 100644 --- a/api/db.go +++ b/api/db.go @@ -20,8 +20,8 @@ package api import ( "encoding/json" "fmt" - "github.com/tlinden/cenophane/cfg" - "github.com/tlinden/cenophane/common" + "github.com/tlinden/ephemerup/cfg" + "github.com/tlinden/ephemerup/common" //"github.com/alecthomas/repr" bolt "go.etcd.io/bbolt" ) diff --git a/api/fileio.go b/api/fileio.go index 9ad11aa..523e05c 100644 --- a/api/fileio.go +++ b/api/fileio.go @@ -21,8 +21,8 @@ import ( "archive/zip" "errors" "github.com/gofiber/fiber/v2" - "github.com/tlinden/cenophane/cfg" - "github.com/tlinden/cenophane/common" + "github.com/tlinden/ephemerup/cfg" + "github.com/tlinden/ephemerup/common" "io" "mime/multipart" "os" diff --git a/api/handlers.go b/api/handlers.go index f9ad2c0..086b9f6 100644 --- a/api/handlers.go +++ b/api/handlers.go @@ -21,8 +21,8 @@ import ( //"github.com/alecthomas/repr" "github.com/gofiber/fiber/v2" "github.com/google/uuid" - "github.com/tlinden/cenophane/cfg" - "github.com/tlinden/cenophane/common" + "github.com/tlinden/ephemerup/cfg" + "github.com/tlinden/ephemerup/common" "os" "path/filepath" diff --git a/api/server.go b/api/server.go index 54a0a22..7da9dc8 100644 --- a/api/server.go +++ b/api/server.go @@ -26,8 +26,8 @@ import ( "github.com/gofiber/fiber/v2/middleware/requestid" "github.com/gofiber/fiber/v2/middleware/session" "github.com/gofiber/keyauth/v2" - "github.com/tlinden/cenophane/cfg" - "github.com/tlinden/cenophane/common" + "github.com/tlinden/ephemerup/cfg" + "github.com/tlinden/ephemerup/common" ) // sessions are context specific and can be global savely @@ -128,7 +128,7 @@ func SetupServer(conf *cfg.Config) *fiber.App { StrictRouting: true, Immutable: true, Prefork: conf.Prefork, - ServerHeader: "Cenophane Server", + ServerHeader: "ephemerup Server", AppName: conf.AppName, BodyLimit: conf.BodyLimit, Network: conf.Network, diff --git a/api/utils.go b/api/utils.go index 57d962e..d26b830 100644 --- a/api/utils.go +++ b/api/utils.go @@ -20,8 +20,8 @@ package api import ( "fmt" "github.com/gofiber/fiber/v2" - "github.com/tlinden/cenophane/cfg" - "github.com/tlinden/cenophane/common" + "github.com/tlinden/ephemerup/cfg" + "github.com/tlinden/ephemerup/common" "time" ) diff --git a/cfg/config.go b/cfg/config.go index 5f582c1..708b7f6 100644 --- a/cfg/config.go +++ b/cfg/config.go @@ -70,7 +70,7 @@ func Getversion() string { // main branch, and cfg.Version-$branch-$lastcommit-$date on // development branch - return fmt.Sprintf("This is cenophane server version %s", VERSION) + return fmt.Sprintf("This is ephemerup server version %s", VERSION) } func (c *Config) GetVersion() string { diff --git a/cmd/root.go b/cmd/root.go index 2c99b0b..c955df9 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -29,8 +29,8 @@ import ( flag "github.com/spf13/pflag" "github.com/alecthomas/repr" - "github.com/tlinden/cenophane/api" - "github.com/tlinden/cenophane/cfg" + "github.com/tlinden/ephemerup/api" + "github.com/tlinden/ephemerup/cfg" "io/ioutil" "os" @@ -71,7 +71,7 @@ func Execute() error { f.BoolVarP(&conf.V6only, "ipv6", "6", false, "Only listen on ipv6") f.BoolVarP(&conf.Prefork, "prefork", "p", false, "Prefork server threads") - f.StringVarP(&conf.AppName, "appname", "n", "cenod "+conf.GetVersion(), "App name to say hi as") + f.StringVarP(&conf.AppName, "appname", "n", "ephemerupd "+conf.GetVersion(), "App name to say hi as") f.IntVarP(&conf.BodyLimit, "bodylimit", "b", 10250000000, "Max allowed upload size in bytes") f.Parse(os.Args[1:]) @@ -91,10 +91,10 @@ func Execute() error { configfiles = []string{configfile} } else { configfiles = []string{ - "/etc/cenod.hcl", "/usr/local/etc/cenod.hcl", // unix variants - filepath.Join(os.Getenv("HOME"), ".config", "cenod", "cenod.hcl"), - filepath.Join(os.Getenv("HOME"), ".cenod"), - "cenod.hcl", + "/etc/ephemerupd.hcl", "/usr/local/etc/ephemerupd.hcl", // unix variants + filepath.Join(os.Getenv("HOME"), ".config", "ephemerupd", "ephemerupd.hcl"), + filepath.Join(os.Getenv("HOME"), ".ephemerupd"), + "ephemerupd.hcl", } } @@ -108,9 +108,9 @@ func Execute() error { } // env overrides config file - k.Load(env.Provider("CENOD_", ".", func(s string) string { + k.Load(env.Provider("EPHEMERUPD_", ".", func(s string) string { return strings.Replace(strings.ToLower( - strings.TrimPrefix(s, "CENOD_")), "_", ".", -1) + strings.TrimPrefix(s, "EPHEMERUPD_")), "_", ".", -1) }), nil) // command line overrides env @@ -157,11 +157,11 @@ func Execute() error { Multiple env vars are supported in this format: - CENOD_CONTEXT_$(NAME)=":" + EPHEMERUPD_CONTEXT_$(NAME)=":" eg: - CENOD_CONTEXT_SUPPORT="support:tymag-fycyh-gymof-dysuf-doseb-puxyx" + EPHEMERUPD_CONTEXT_SUPPORT="support:tymag-fycyh-gymof-dysuf-doseb-puxyx" ^^^^^^^- doesn't matter. Modifies cfg.Config directly @@ -171,7 +171,7 @@ func GetApicontextsFromEnv(conf *cfg.Config) { for _, envvar := range os.Environ() { pair := strings.SplitN(envvar, "=", 2) - if strings.HasPrefix(pair[0], "CENOD_CONTEXT_") { + if strings.HasPrefix(pair[0], "EPHEMERUPD_CONTEXT_") { c := strings.SplitN(pair[1], ":", 2) if len(c) == 2 { contexts = append(contexts, cfg.Apicontext{Context: c[0], Key: c[1]}) diff --git a/common/go.mod b/common/go.mod index 06d829b..e70a9b7 100644 --- a/common/go.mod +++ b/common/go.mod @@ -1,3 +1,3 @@ -module github.com/tlinden/cenophane/common +module github.com/tlinden/ephemerup/common go 1.18 diff --git a/docker-compose.yml b/docker-compose.yml index f2933be..a2f52a9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ version: "3.9" services: - cenophane: + ephemerup: build: . ports: - "8080:8080" diff --git a/cenod.hcl b/ephemerupd.hcl similarity index 100% rename from cenod.hcl rename to ephemerupd.hcl diff --git a/go.mod b/go.mod index 8899487..a328b6e 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/tlinden/cenophane +module github.com/tlinden/ephemerup go 1.18 @@ -13,7 +13,7 @@ require ( github.com/knadh/koanf/providers/posflag v0.1.0 github.com/knadh/koanf/v2 v2.0.0 github.com/spf13/pflag v1.0.5 - github.com/tlinden/cenophane/common v0.0.0-00010101000000-000000000000 + github.com/tlinden/ephemerup/common v0.0.0-00010101000000-000000000000 go.etcd.io/bbolt v1.3.7 ) @@ -40,4 +40,4 @@ require ( golang.org/x/sys v0.4.0 // indirect ) -replace github.com/tlinden/cenophane/common => ./common +replace github.com/tlinden/ephemerup/common => ./common diff --git a/main.go b/main.go index 720e918..6957212 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,7 @@ along with this program. If not, see . package main import ( - "github.com/tlinden/cenophane/cmd" + "github.com/tlinden/ephemerup/cmd" "log" ) diff --git a/upctl/Makefile b/upctl/Makefile index dbadb30..636da5d 100644 --- a/upctl/Makefile +++ b/upctl/Makefile @@ -33,7 +33,7 @@ all: buildlocal buildlocal: - go build -ldflags "-X 'github.com/tlinden/cenophane/upctl/cfg.VERSION=$(VERSION)'" + go build -ldflags "-X 'github.com/tlinden/ephemerup/upctl/cfg.VERSION=$(VERSION)'" release: ./mkrel.sh $(tool) $(version) diff --git a/upctl/cmd/delete.go b/upctl/cmd/delete.go index 74d079d..4bcf059 100644 --- a/upctl/cmd/delete.go +++ b/upctl/cmd/delete.go @@ -19,8 +19,8 @@ package cmd import ( "errors" "github.com/spf13/cobra" - "github.com/tlinden/cenophane/upctl/cfg" - "github.com/tlinden/cenophane/upctl/lib" + "github.com/tlinden/ephemerup/upctl/cfg" + "github.com/tlinden/ephemerup/upctl/lib" ) func DeleteCommand(conf *cfg.Config) *cobra.Command { diff --git a/upctl/cmd/describe.go b/upctl/cmd/describe.go index f38a1a7..9ffd619 100644 --- a/upctl/cmd/describe.go +++ b/upctl/cmd/describe.go @@ -19,8 +19,8 @@ package cmd import ( "errors" "github.com/spf13/cobra" - "github.com/tlinden/cenophane/upctl/cfg" - "github.com/tlinden/cenophane/upctl/lib" + "github.com/tlinden/ephemerup/upctl/cfg" + "github.com/tlinden/ephemerup/upctl/lib" ) func DescribeCommand(conf *cfg.Config) *cobra.Command { diff --git a/upctl/cmd/download.go b/upctl/cmd/download.go index ed12624..9e7ae72 100644 --- a/upctl/cmd/download.go +++ b/upctl/cmd/download.go @@ -19,8 +19,8 @@ package cmd import ( "errors" "github.com/spf13/cobra" - "github.com/tlinden/cenophane/upctl/cfg" - "github.com/tlinden/cenophane/upctl/lib" + "github.com/tlinden/ephemerup/upctl/cfg" + "github.com/tlinden/ephemerup/upctl/lib" ) func DownloadCommand(conf *cfg.Config) *cobra.Command { diff --git a/upctl/cmd/list.go b/upctl/cmd/list.go index 4d9ac65..10a6f3d 100644 --- a/upctl/cmd/list.go +++ b/upctl/cmd/list.go @@ -18,8 +18,8 @@ package cmd import ( "github.com/spf13/cobra" - "github.com/tlinden/cenophane/upctl/cfg" - "github.com/tlinden/cenophane/upctl/lib" + "github.com/tlinden/ephemerup/upctl/cfg" + "github.com/tlinden/ephemerup/upctl/lib" ) func ListCommand(conf *cfg.Config) *cobra.Command { diff --git a/upctl/cmd/root.go b/upctl/cmd/root.go index d1f953d..947dc3e 100644 --- a/upctl/cmd/root.go +++ b/upctl/cmd/root.go @@ -22,7 +22,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/spf13/viper" - "github.com/tlinden/cenophane/upctl/cfg" + "github.com/tlinden/ephemerup/upctl/cfg" "os" "strings" ) diff --git a/upctl/cmd/upload.go b/upctl/cmd/upload.go index a271692..2daaffd 100644 --- a/upctl/cmd/upload.go +++ b/upctl/cmd/upload.go @@ -19,8 +19,8 @@ package cmd import ( "errors" "github.com/spf13/cobra" - "github.com/tlinden/cenophane/upctl/cfg" - "github.com/tlinden/cenophane/upctl/lib" + "github.com/tlinden/ephemerup/upctl/cfg" + "github.com/tlinden/ephemerup/upctl/lib" ) func UploadCommand(conf *cfg.Config) *cobra.Command { diff --git a/upctl/go.mod b/upctl/go.mod index 6b4ff8d..c613ae3 100644 --- a/upctl/go.mod +++ b/upctl/go.mod @@ -1,4 +1,4 @@ -module github.com/tlinden/cenophane/upctl +module github.com/tlinden/ephemerup/upctl go 1.18 @@ -10,7 +10,7 @@ require ( github.com/spf13/cobra v1.6.1 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.15.0 - github.com/tlinden/cenophane/common v0.0.0-00010101000000-000000000000 + github.com/tlinden/ephemerup/common v0.0.0-00010101000000-000000000000 ) require ( @@ -50,4 +50,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/tlinden/cenophane/common => ../common +replace github.com/tlinden/ephemerup/common => ../common diff --git a/upctl/lib/client.go b/upctl/lib/client.go index b8befac..81e13f7 100644 --- a/upctl/lib/client.go +++ b/upctl/lib/client.go @@ -25,8 +25,8 @@ import ( "github.com/imroc/req/v3" "github.com/jarcoal/httpmock" "github.com/schollz/progressbar/v3" - "github.com/tlinden/cenophane/common" - "github.com/tlinden/cenophane/upctl/cfg" + "github.com/tlinden/ephemerup/common" + "github.com/tlinden/ephemerup/upctl/cfg" "mime" "os" "path/filepath" diff --git a/upctl/lib/client_test.go b/upctl/lib/client_test.go index 578f38e..5ec0da0 100644 --- a/upctl/lib/client_test.go +++ b/upctl/lib/client_test.go @@ -21,7 +21,7 @@ import ( //"github.com/alecthomas/repr" "fmt" "github.com/jarcoal/httpmock" - "github.com/tlinden/cenophane/upctl/cfg" + "github.com/tlinden/ephemerup/upctl/cfg" "net/http" "testing" ) @@ -39,7 +39,7 @@ type Unit struct { method string // method to use } -// simulate our cenophane server +// simulate our ephemerup server func Intercept(tt Unit) { httpmock.RegisterResponder(tt.method, endpoint+tt.route, func(request *http.Request) (*http.Response, error) { diff --git a/upctl/lib/output.go b/upctl/lib/output.go index 2d70b32..ec0a99b 100644 --- a/upctl/lib/output.go +++ b/upctl/lib/output.go @@ -23,7 +23,7 @@ import ( "fmt" "github.com/imroc/req/v3" "github.com/olekukonko/tablewriter" - "github.com/tlinden/cenophane/common" + "github.com/tlinden/ephemerup/common" "os" "time" ) diff --git a/upctl/main.go b/upctl/main.go index c11a498..a7aa748 100644 --- a/upctl/main.go +++ b/upctl/main.go @@ -18,7 +18,7 @@ along with this program. If not, see . package main import ( - "github.com/tlinden/cenophane/upctl/cmd" + "github.com/tlinden/ephemerup/upctl/cmd" ) func main() {