repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
2cf902e
parent
11d6ebe
author
Eric Bower
date
2022-09-07 01:15:31 +0000 UTC
docs: remove wish/readme since it's out of date
1 files changed,  +0, -169
D wish/README.md
+0, -169
  1@@ -1,169 +0,0 @@
  2-# wish middleware
  3-
  4-This repo contains a collection of wish middleware we've built for our
  5-services.
  6-
  7-- [cms](#cms)
  8-- [send](#send)
  9-- [proxy](#proxy)
 10-
 11-## comms
 12-
 13-- [website](https://pico.sh)
 14-- [irc #pico.sh](irc://irc.libera.chat/#pico.sh)
 15-- [mailing list](https://lists.sr.ht/~erock/pico.sh)
 16-- [ticket tracker](https://todo.sr.ht/~erock/pico.sh)
 17-- [email](mailto:hello@pico.sh)
 18-
 19-## cms
 20-
 21-A content management system wish ssh app.  The goal of this library is to
 22-provide a wish middleware that lets users ssh into this app to manage their
 23-account as well as their posts.
 24-
 25-### setup
 26-
 27-You are responsible for creating your own sql tables.  A copy of the schema is
 28-in this repo.
 29-
 30-### example
 31-
 32-```go
 33-import (
 34-  "github.com/charmbracelet/wish"
 35-  bm "github.com/charmbracelet/wish/bubbletea"
 36-  "github.com/gliderlabs/ssh"
 37-  "git.sr.ht/~erock/pico/wish/cms"
 38-  "git.sr.ht/~erock/pico/wish/cms/config"
 39-)
 40-
 41-type SSHServer struct{}
 42-func (me *SSHServer) authHandler(ctx ssh.Context, key ssh.PublicKey) bool {
 43-	return true
 44-}
 45-
 46-func main() {
 47-  cfg := config.NewConfigCms()
 48-  handler := cms.Middleware(cfg)
 49-
 50-  sshServer := &SSHServer{}
 51-  s, err := wish.NewServer(
 52-    wish.WithAddress(fmt.Sprintf("%s:%s", "localhost", "2222")),
 53-    wish.WithHostKeyPath("ssh_data/term_info_ed25519"),
 54-    wish.WithPublicKeyAuth(sshServer.authHandler),
 55-    wish.WithMiddleware(bm.Middleware(handler)),
 56-  )
 57-
 58-  // ... the rest of the wish initialization
 59-}
 60-```
 61-
 62-## send
 63-
 64-wish middleware to allow secure file transfers with scp or sftp
 65-
 66-### example
 67-
 68-```go
 69-package main
 70-
 71-import (
 72-    "github.com/charmbracelet/wish"
 73-    "github.com/neurosnap/lists.sh/internal/db/postgres"
 74-    "git.sr.ht/~erock/pico/wish/send"
 75-)
 76-
 77-type SSHServer struct{}
 78-
 79-func (me *SSHServer) authHandler(ctx ssh.Context, key ssh.PublicKey) bool {
 80-    return true
 81-}
 82-
 83-func main() {
 84-    host := "0.0.0.0"
 85-    port := "2222"
 86-    
 87-    handler := &send.DbHandler{}
 88-    
 89-    dbh := postgres.NewDB()
 90-    defer dbh.Close()
 91-    
 92-    sshServer := &SSHServer{}
 93-
 94-    s, err := wish.NewServer(
 95-        wish.WithAddress(fmt.Sprintf("%s:%s", host, port)),
 96-        wish.WithHostKeyPath("ssh_data/term_info_ed25519"),
 97-        wish.WithPublicKeyAuth(sshServer.authHandler),
 98-        wish.WithMiddleware(send.Middleware(handler)),
 99-    )
100-    if err != nil {
101-        panic(err)
102-    }
103-
104-    done := make(chan os.Signal, 1)
105-    signal.Notify(done, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
106-    
107-    fmt.Printf("Starting SSH server on %s:%s\n", host, port)
108-    
109-    go func() {
110-        if err = s.ListenAndServe(); err != nil {
111-            panic(err)
112-        }
113-    }()
114-
115-    <-done
116-    
117-    fmt.Println("Stopping SSH server")
118-    
119-    ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
120-    defer func() { cancel() }()
121-    
122-    if err := s.Shutdown(ctx); err != nil {
123-        panic(err)
124-    }
125-}
126-```
127-
128-## proxy
129-
130-A command-based proxy middleware for your wish ssh apps. If you have ssh apps that only run on
131-certain ssh commands, this middleware will help you.
132-
133-### example
134-
135-```go
136-package example
137-
138-import (
139-	"github.com/charmbracelet/wish"
140-	"github.com/gliderlabs/ssh"
141-	wp "git.sr.ht/~erock/pico/wish/proxy"
142-)
143-
144-func router(sh ssh.Handler, s ssh.Session) []wish.Middleware {
145-	cmd := s.Command()
146-	mdw := []wish.Middleware{}
147-
148-	if len(cmd) == 0 {
149-		mdw = append(mdw, lm.Middleware())
150-	} else if cmd[0] == "scp" {
151-		mdw = append(mdw, scp.Middleware())
152-	}
153-
154-	return mdw
155-}
156-
157-func main() {
158-	s, err := wish.NewServer(
159-		wish.WithAddress(fmt.Sprintf("%s:%s", host, port)),
160-		wish.WithHostKeyPath("ssh_data/term_info_ed25519"),
161-		wp.WithProxy(router),
162-	)
163-}
164-```
165-
166-## attribution
167-
168-- [Wish (middleware and SCP support)](https://github.com/charmbracelet/wish)
169-- [UI inspiration](https://github.com/charmbracelet/charm)
170-- [Go SFTP (SFTP support)](https://github.com/pkg/sftp)