Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
e3c1f9d54b | |||
9195bba7ed | |||
a7e5c99cec | |||
c6cfdf9e9f | |||
09c7eb8318 |
17 changed files with 360 additions and 62 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,4 +2,5 @@ node_modules/
|
||||||
frontend/dist/*.js
|
frontend/dist/*.js
|
||||||
frontend/.js
|
frontend/.js
|
||||||
underbbs
|
underbbs
|
||||||
|
underbbs-cli
|
||||||
__debug_*
|
__debug_*
|
10
README.md
10
README.md
|
@ -1,15 +1,23 @@
|
||||||
# underBBS
|
# underBBS
|
||||||
|
|
||||||
underBBS is a platform-agnostic messaging and social media client
|
underBBS is a protocol-agnostic decentralized social media client and toolkit
|
||||||
|
|
||||||
## design
|
## design
|
||||||
|
|
||||||
|
`underbbs` can run in two modes depending on its executable name:
|
||||||
|
|
||||||
|
### web client
|
||||||
|
|
||||||
`underbbs` supports multiple simultaneous account logins, mediating them for each user through a gateway server that handles all protocol-specific logic via `adapter`s and streaming content to the user through a single websocket connection with a singular data interface.
|
`underbbs` supports multiple simultaneous account logins, mediating them for each user through a gateway server that handles all protocol-specific logic via `adapter`s and streaming content to the user through a single websocket connection with a singular data interface.
|
||||||
|
|
||||||
each distinct `adapter` connection/configuration is represented in the frontend as a tab, and using the websocket's event-driven javascript interface with web components we can simply either store the data or tell the currently visible adapter that it might need to respond to the new data
|
each distinct `adapter` connection/configuration is represented in the frontend as a tab, and using the websocket's event-driven javascript interface with web components we can simply either store the data or tell the currently visible adapter that it might need to respond to the new data
|
||||||
|
|
||||||
adapters receive commands via a quartzgun web API and send data back on their shared websocket connection
|
adapters receive commands via a quartzgun web API and send data back on their shared websocket connection
|
||||||
|
|
||||||
|
### CLI
|
||||||
|
|
||||||
|
`underbbs-cli` pulls adapter credentials from `~/.config/underbbs/cli.conf` and accepts commands on individual adapters, printing data to standard output.
|
||||||
|
|
||||||
## building and running
|
## building and running
|
||||||
|
|
||||||
requirements are
|
requirements are
|
||||||
|
|
|
@ -5,10 +5,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Adapter interface {
|
type Adapter interface {
|
||||||
Init(Settings, chan SocketData) error
|
Init(Settings, *chan SocketData) error
|
||||||
Name() string
|
Name() string
|
||||||
Subscribe(string) []error
|
Subscribe(string) []error
|
||||||
Fetch(string, []string) error
|
Fetch(string, []string) error
|
||||||
Do(string) error
|
Do(string, map[string]string) error
|
||||||
DefaultSubscriptionFilter() string
|
DefaultSubscriptionFilter() string
|
||||||
}
|
}
|
||||||
|
|
96
adapter/honk.go
Normal file
96
adapter/honk.go
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
package adapter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
. "forge.lightcrystal.systems/lightcrystal/underbbs/models"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type HonkAdapter struct {
|
||||||
|
data *chan SocketData
|
||||||
|
nickname string
|
||||||
|
server string
|
||||||
|
username string
|
||||||
|
password string
|
||||||
|
token string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *HonkAdapter) send(data SocketData) {
|
||||||
|
if self.data != nil {
|
||||||
|
*self.data <- data
|
||||||
|
} else {
|
||||||
|
fmt.Fprintln(os.Stdout, string(data.ToDatagram()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *HonkAdapter) Name() string {
|
||||||
|
return self.nickname
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *HonkAdapter) Init(settings Settings, data *chan SocketData) error {
|
||||||
|
// separate name and server in handle
|
||||||
|
parts := strings.Split(*settings.Handle, "@")
|
||||||
|
self.username = parts[1]
|
||||||
|
self.server = "https://" + parts[2]
|
||||||
|
self.password = *settings.Password
|
||||||
|
self.nickname = settings.Nickname
|
||||||
|
// store all the settings
|
||||||
|
// make a request to get the token
|
||||||
|
r, err := http.PostForm(self.server+"/dologin", url.Values{
|
||||||
|
"username": []string{self.username},
|
||||||
|
"password": []string{self.password},
|
||||||
|
"gettoken": []string{"1"},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf [32]byte
|
||||||
|
_, err = r.Body.Read(buf[:])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
self.token = string(buf[:])
|
||||||
|
fmt.Println(self.token)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *HonkAdapter) Subscribe(string) []error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *HonkAdapter) Fetch(etype string, ids []string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *HonkAdapter) Do(action string, data map[string]string) error {
|
||||||
|
switch action {
|
||||||
|
case "post":
|
||||||
|
res, err := http.PostForm(self.server+"/api", url.Values{
|
||||||
|
"action": []string{"honk"},
|
||||||
|
"token": []string{self.token},
|
||||||
|
"noise": []string{data["content"]},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var buf [256]byte
|
||||||
|
_, err = res.Body.Read(buf[:])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Println(string(buf[:]))
|
||||||
|
default:
|
||||||
|
return errors.New("Do: unknown action")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *HonkAdapter) DefaultSubscriptionFilter() string {
|
||||||
|
return ""
|
||||||
|
}
|
|
@ -4,10 +4,12 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
. "forge.lightcrystal.systems/lightcrystal/underbbs/models"
|
. "forge.lightcrystal.systems/lightcrystal/underbbs/models"
|
||||||
madon "github.com/McKael/madon"
|
madon "github.com/McKael/madon"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MastoAdapter struct {
|
type MastoAdapter struct {
|
||||||
data chan SocketData
|
data *chan SocketData
|
||||||
nickname string
|
nickname string
|
||||||
server string
|
server string
|
||||||
apiKey string
|
apiKey string
|
||||||
|
@ -21,11 +23,19 @@ type MastoAdapter struct {
|
||||||
|
|
||||||
var scopes = []string{"read", "write", "follow"}
|
var scopes = []string{"read", "write", "follow"}
|
||||||
|
|
||||||
|
func (self *MastoAdapter) send(data SocketData) {
|
||||||
|
if self.data != nil {
|
||||||
|
*self.data <- data
|
||||||
|
} else {
|
||||||
|
fmt.Println(os.Stdout, string(data.ToDatagram()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (self *MastoAdapter) Name() string {
|
func (self *MastoAdapter) Name() string {
|
||||||
return self.nickname
|
return self.nickname
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *MastoAdapter) Init(settings Settings, data chan SocketData) error {
|
func (self *MastoAdapter) Init(settings Settings, data *chan SocketData) error {
|
||||||
self.nickname = settings.Nickname
|
self.nickname = settings.Nickname
|
||||||
self.server = *settings.Server
|
self.server = *settings.Server
|
||||||
self.apiKey = *settings.ApiKey
|
self.apiKey = *settings.ApiKey
|
||||||
|
@ -62,7 +72,7 @@ func (self *MastoAdapter) Subscribe(filter string) []error {
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
for e := range self.events {
|
for e := range self.events {
|
||||||
fmt.Println("event: %s !!!", e.Event)
|
log.Printf("event: %s !!!", e.Event)
|
||||||
switch e.Event {
|
switch e.Event {
|
||||||
case "error":
|
case "error":
|
||||||
case "update":
|
case "update":
|
||||||
|
@ -77,7 +87,7 @@ func (self *MastoAdapter) Subscribe(filter string) []error {
|
||||||
msg = self.mastoUpdateToMessage(v)
|
msg = self.mastoUpdateToMessage(v)
|
||||||
}
|
}
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
self.data <- msg
|
self.send(msg)
|
||||||
}
|
}
|
||||||
case "notification":
|
case "notification":
|
||||||
case "delete":
|
case "delete":
|
||||||
|
@ -94,7 +104,7 @@ func (self *MastoAdapter) Fetch(etype string, ids []string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *MastoAdapter) Do(action string) error {
|
func (self *MastoAdapter) Do(action string, data map[string]string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,15 @@ import (
|
||||||
n "github.com/yitsushi/go-misskey/services/notes"
|
n "github.com/yitsushi/go-misskey/services/notes"
|
||||||
tl "github.com/yitsushi/go-misskey/services/notes/timeline"
|
tl "github.com/yitsushi/go-misskey/services/notes/timeline"
|
||||||
users "github.com/yitsushi/go-misskey/services/users"
|
users "github.com/yitsushi/go-misskey/services/users"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MisskeyAdapter struct {
|
type MisskeyAdapter struct {
|
||||||
data chan SocketData
|
data *chan SocketData
|
||||||
nickname string
|
nickname string
|
||||||
server string
|
server string
|
||||||
apiKey string
|
apiKey string
|
||||||
|
@ -31,19 +33,27 @@ type MisskeyAdapter struct {
|
||||||
stop chan bool
|
stop chan bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *MisskeyAdapter) send(data SocketData) {
|
||||||
|
if self.data != nil {
|
||||||
|
*self.data <- data
|
||||||
|
} else {
|
||||||
|
fmt.Fprintln(os.Stderr, string(data.ToDatagram()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (self *MisskeyAdapter) Name() string {
|
func (self *MisskeyAdapter) Name() string {
|
||||||
return self.nickname
|
return self.nickname
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *MisskeyAdapter) Init(settings Settings, data chan SocketData) error {
|
func (self *MisskeyAdapter) Init(settings Settings, data *chan SocketData) error {
|
||||||
fmt.Println("initializing misskey adapter")
|
log.Print("initializing misskey adapter")
|
||||||
|
|
||||||
self.nickname = settings.Nickname
|
self.nickname = settings.Nickname
|
||||||
self.server = *settings.Server
|
self.server = *settings.Server
|
||||||
self.apiKey = *settings.ApiKey
|
self.apiKey = *settings.ApiKey
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
||||||
fmt.Println("getting ready to initialize internal client")
|
log.Print("getting ready to initialize internal client")
|
||||||
|
|
||||||
client, err := misskey.NewClientWithOptions(
|
client, err := misskey.NewClientWithOptions(
|
||||||
misskey.WithAPIToken(self.apiKey),
|
misskey.WithAPIToken(self.apiKey),
|
||||||
|
@ -51,10 +61,10 @@ func (self *MisskeyAdapter) Init(settings Settings, data chan SocketData) error
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error())
|
log.Print(err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println("misskey client initialized")
|
log.Print("misskey client initialized")
|
||||||
self.mk = client
|
self.mk = client
|
||||||
|
|
||||||
self.cache = make(map[string]time.Time)
|
self.cache = make(map[string]time.Time)
|
||||||
|
@ -119,10 +129,10 @@ func (self *MisskeyAdapter) poll() {
|
||||||
Limit: 100,
|
Limit: 100,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error())
|
log.Print(err.Error())
|
||||||
}
|
}
|
||||||
if merr != nil {
|
if merr != nil {
|
||||||
fmt.Println(merr.Error())
|
log.Print(merr.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the cache for everything we just collected
|
// check the cache for everything we just collected
|
||||||
|
@ -131,13 +141,13 @@ func (self *MisskeyAdapter) poll() {
|
||||||
for _, n := range notes {
|
for _, n := range notes {
|
||||||
msg := self.toMessageIfNew(n)
|
msg := self.toMessageIfNew(n)
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
self.data <- msg
|
self.send(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, n := range mentions {
|
for _, n := range mentions {
|
||||||
msg := self.toMessageIfNew(n)
|
msg := self.toMessageIfNew(n)
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
self.data <- msg
|
self.send(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +160,7 @@ func (self *MisskeyAdapter) poll() {
|
||||||
Limit: 100,
|
Limit: 100,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error())
|
log.Print(err.Error())
|
||||||
}
|
}
|
||||||
for _, n := range notes {
|
for _, n := range notes {
|
||||||
msg := self.toMessageIfNew(n)
|
msg := self.toMessageIfNew(n)
|
||||||
|
@ -158,7 +168,7 @@ func (self *MisskeyAdapter) poll() {
|
||||||
latest = &probenote[0].CreatedAt
|
latest = &probenote[0].CreatedAt
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
self.data <- msg
|
self.send(msg)
|
||||||
}
|
}
|
||||||
if *latest == probenote[0].CreatedAt {
|
if *latest == probenote[0].CreatedAt {
|
||||||
break
|
break
|
||||||
|
@ -216,6 +226,7 @@ func (self *MisskeyAdapter) toMessage(n mkm.Note, bustCache bool) *Message {
|
||||||
ReplyTo: n.ReplyID,
|
ReplyTo: n.ReplyID,
|
||||||
ReplyCount: int(n.RepliesCount),
|
ReplyCount: int(n.RepliesCount),
|
||||||
Replies: []string{},
|
Replies: []string{},
|
||||||
|
RenoteId: (*string)(n.RenoteID),
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, f := range n.Files {
|
for _, f := range n.Files {
|
||||||
|
@ -253,7 +264,7 @@ func (self *MisskeyAdapter) toAuthor(usr mkm.User, bustCache bool) *Author {
|
||||||
}
|
}
|
||||||
|
|
||||||
if bustCache || !exists || (updated != nil && timestamp.Before(time.UnixMilli(*updated))) || timestamp.Before(*usr.CreatedAt) {
|
if bustCache || !exists || (updated != nil && timestamp.Before(time.UnixMilli(*updated))) || timestamp.Before(*usr.CreatedAt) {
|
||||||
fmt.Println("converting author: " + usr.ID)
|
log.Print("converting author: " + usr.ID)
|
||||||
if usr.UpdatedAt != nil {
|
if usr.UpdatedAt != nil {
|
||||||
self.cache[authorId] = *usr.UpdatedAt
|
self.cache[authorId] = *usr.UpdatedAt
|
||||||
} else {
|
} else {
|
||||||
|
@ -283,6 +294,8 @@ func (self *MisskeyAdapter) toAuthor(usr mkm.User, bustCache bool) *Author {
|
||||||
func (self *MisskeyAdapter) Fetch(etype string, ids []string) error {
|
func (self *MisskeyAdapter) Fetch(etype string, ids []string) error {
|
||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
switch etype {
|
switch etype {
|
||||||
|
case "byAuthor":
|
||||||
|
// fetch notes by this author
|
||||||
case "message":
|
case "message":
|
||||||
data, err := self.mk.Notes().Show(id)
|
data, err := self.mk.Notes().Show(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -290,7 +303,7 @@ func (self *MisskeyAdapter) Fetch(etype string, ids []string) error {
|
||||||
} else {
|
} else {
|
||||||
msg := self.toMessage(data, true)
|
msg := self.toMessage(data, true)
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
self.data <- msg
|
self.send(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "children":
|
case "children":
|
||||||
|
@ -304,7 +317,7 @@ func (self *MisskeyAdapter) Fetch(etype string, ids []string) error {
|
||||||
for _, n := range data {
|
for _, n := range data {
|
||||||
msg := self.toMessage(n, true)
|
msg := self.toMessage(n, true)
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
self.data <- msg
|
self.send(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -319,7 +332,7 @@ func (self *MisskeyAdapter) Fetch(etype string, ids []string) error {
|
||||||
for _, n := range data {
|
for _, n := range data {
|
||||||
msg := self.toMessage(n, true)
|
msg := self.toMessage(n, true)
|
||||||
if msg != nil {
|
if msg != nil {
|
||||||
self.data <- msg
|
self.send(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,7 +350,6 @@ func (self *MisskeyAdapter) Fetch(etype string, ids []string) error {
|
||||||
hostPtr = &host
|
hostPtr = &host
|
||||||
}
|
}
|
||||||
|
|
||||||
// fmt.Printf("attempting user resolution: @%s@%s\n", user, host)
|
|
||||||
data, err := self.mk.Users().Show(users.ShowRequest{
|
data, err := self.mk.Users().Show(users.ShowRequest{
|
||||||
Username: &user,
|
Username: &user,
|
||||||
Host: hostPtr,
|
Host: hostPtr,
|
||||||
|
@ -347,16 +359,16 @@ func (self *MisskeyAdapter) Fetch(etype string, ids []string) error {
|
||||||
} else {
|
} else {
|
||||||
a := self.toAuthor(data, false)
|
a := self.toAuthor(data, false)
|
||||||
if a != nil {
|
if a != nil {
|
||||||
self.data <- a
|
self.send(a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *MisskeyAdapter) Do(action string) error {
|
func (self *MisskeyAdapter) Do(action string, data map[string]string) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,21 +7,31 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
. "forge.lightcrystal.systems/lightcrystal/underbbs/models"
|
. "forge.lightcrystal.systems/lightcrystal/underbbs/models"
|
||||||
nostr "github.com/nbd-wtf/go-nostr"
|
nostr "github.com/nbd-wtf/go-nostr"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NostrAdapter struct {
|
type NostrAdapter struct {
|
||||||
data chan SocketData
|
data *chan SocketData
|
||||||
nickname string
|
nickname string
|
||||||
privkey string
|
privkey string
|
||||||
relays []*nostr.Relay
|
relays []*nostr.Relay
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *NostrAdapter) send(data SocketData) {
|
||||||
|
if self.data != nil {
|
||||||
|
*self.data <- data
|
||||||
|
} else {
|
||||||
|
fmt.Fprintln(os.Stdout, string(data.ToDatagram()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (self *NostrAdapter) Name() string {
|
func (self *NostrAdapter) Name() string {
|
||||||
return self.nickname
|
return self.nickname
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *NostrAdapter) Init(settings Settings, data chan SocketData) error {
|
func (self *NostrAdapter) Init(settings Settings, data *chan SocketData) error {
|
||||||
self.nickname = settings.Nickname
|
self.nickname = settings.Nickname
|
||||||
self.privkey = *settings.PrivKey
|
self.privkey = *settings.PrivKey
|
||||||
self.data = data
|
self.data = data
|
||||||
|
@ -47,35 +57,32 @@ func (self *NostrAdapter) Subscribe(filter string) []error {
|
||||||
|
|
||||||
errs := make([]error, 0)
|
errs := make([]error, 0)
|
||||||
|
|
||||||
fmt.Print("unmarshalled filter from json; iterating through relays to subscribe..")
|
log.Print("unmarshalled filter from json; iterating through relays to subscribe...")
|
||||||
|
|
||||||
for _, r := range self.relays {
|
for _, r := range self.relays {
|
||||||
fmt.Print(".")
|
|
||||||
sub, err := r.Subscribe(context.Background(), filters)
|
sub, err := r.Subscribe(context.Background(), filters)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
} else {
|
} else {
|
||||||
go func() {
|
go func() {
|
||||||
for ev := range sub.Events {
|
for ev := range sub.Events {
|
||||||
fmt.Print("!")
|
|
||||||
// try sequentially to encode into an underbbs object
|
// try sequentially to encode into an underbbs object
|
||||||
// and send it to the appropriate channel
|
// and send it to the appropriate channel
|
||||||
m, err := self.nostrEventToMsg(ev)
|
m, err := self.nostrEventToMsg(ev)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
self.data <- m
|
self.send(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
fmt.Println()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
fmt.Println("subscription operation completed with errors")
|
log.Print("subscription operation completed with errors")
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
fmt.Println("subscription operation completed without errors")
|
log.Print("subscription operation completed without errors")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +90,7 @@ func (self *NostrAdapter) Fetch(etype string, ids []string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *NostrAdapter) Do(action string) error {
|
func (self *NostrAdapter) Do(action string, data map[string]string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
116
cli/cli.go
Normal file
116
cli/cli.go
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
package cli
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"forge.lightcrystal.systems/lightcrystal/underbbs/adapter"
|
||||||
|
"forge.lightcrystal.systems/lightcrystal/underbbs/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetConfigLocation() string {
|
||||||
|
home := os.Getenv("HOME")
|
||||||
|
appdata := os.Getenv("APPDATA")
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "windows":
|
||||||
|
return filepath.Join(appdata, "underbbs")
|
||||||
|
case "darwin":
|
||||||
|
return filepath.Join(home, "Library", "Application Support", "underbbs")
|
||||||
|
case "plan9":
|
||||||
|
return filepath.Join(home, "lib", "underbbs")
|
||||||
|
default:
|
||||||
|
return filepath.Join(home, ".config", "underbbs")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func EnsureConfigLocationExists() {
|
||||||
|
fileInfo, err := os.Stat(GetConfigLocation())
|
||||||
|
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
os.MkdirAll(GetConfigLocation(), os.ModePerm)
|
||||||
|
} else if !fileInfo.IsDir() {
|
||||||
|
panic("Config location is not a directory!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Process(args ...string) error {
|
||||||
|
// allocate storage for the settings array
|
||||||
|
var settings []models.Settings
|
||||||
|
var s *models.Settings
|
||||||
|
|
||||||
|
if len(args) < 3 {
|
||||||
|
return errors.New("CLI requires at least 3 args: ADAPTER ACTION DATA...")
|
||||||
|
}
|
||||||
|
|
||||||
|
EnsureConfigLocationExists()
|
||||||
|
cfgdir := GetConfigLocation()
|
||||||
|
|
||||||
|
// get adapter from first arg
|
||||||
|
adapterName := args[0]
|
||||||
|
args = args[1:]
|
||||||
|
|
||||||
|
// get config from config fle based on adapter
|
||||||
|
content, err := ioutil.ReadFile(filepath.Join(cfgdir, "config.json"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(content, &settings)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, x := range settings {
|
||||||
|
if x.Nickname == adapterName {
|
||||||
|
s = &x
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if s == nil {
|
||||||
|
return errors.New("given adapter " + adapterName + " is not in the config file")
|
||||||
|
}
|
||||||
|
|
||||||
|
// instantiate adapter with config
|
||||||
|
var a adapter.Adapter
|
||||||
|
switch s.Protocol {
|
||||||
|
case "nostr":
|
||||||
|
a = &adapter.NostrAdapter{}
|
||||||
|
case "mastodon":
|
||||||
|
a = &adapter.MastoAdapter{}
|
||||||
|
case "misskey":
|
||||||
|
a = &adapter.MisskeyAdapter{}
|
||||||
|
case "honk":
|
||||||
|
a = &adapter.HonkAdapter{}
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
a.Init(*s, nil)
|
||||||
|
// process remaining args and execute
|
||||||
|
|
||||||
|
switch args[0] {
|
||||||
|
case "fetch":
|
||||||
|
a.Fetch(args[1], args[2:])
|
||||||
|
case "do":
|
||||||
|
data := map[string]string{}
|
||||||
|
for _, a := range args[2:] {
|
||||||
|
if !strings.Contains(a, "=") {
|
||||||
|
return errors.New("args are in the form KEY=VALUE")
|
||||||
|
} else {
|
||||||
|
aa := strings.Split(a, "=")
|
||||||
|
k := aa[0]
|
||||||
|
v := strings.Join(aa[1:], "=")
|
||||||
|
data[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a.Do(args[1], data)
|
||||||
|
default:
|
||||||
|
log.Print(args)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -24,6 +24,7 @@ export class AdapterElement extends HTMLElement {
|
||||||
// TODO: use visibility of the thread to organize into DMs and public threads
|
// TODO: use visibility of the thread to organize into DMs and public threads
|
||||||
private _threads: MessageThread[] = [];
|
private _threads: MessageThread[] = [];
|
||||||
private _orphans: Message[] = [];
|
private _orphans: Message[] = [];
|
||||||
|
private _boosts: Message[] = [];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
@ -102,6 +103,7 @@ export class AdapterElement extends HTMLElement {
|
||||||
tse.setAttribute("data-author", this._latest);
|
tse.setAttribute("data-author", this._latest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// also update any boosts by this author
|
||||||
case "thread":
|
case "thread":
|
||||||
case "profile":
|
case "profile":
|
||||||
break;
|
break;
|
||||||
|
@ -113,7 +115,7 @@ export class AdapterElement extends HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
setIdxView() {
|
setIdxView() {
|
||||||
this.innerHTML = "<ul id='dm_list'></ul><ul id='public_list'></ul>"
|
this.innerHTML = "<ul id='boost_carousel'></ul><ul id='dm_list'></ul><ul id='public_list'></ul>"
|
||||||
}
|
}
|
||||||
|
|
||||||
setThreadView() {
|
setThreadView() {
|
||||||
|
@ -132,6 +134,8 @@ export class AdapterElement extends HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
populateIdxView() {
|
populateIdxView() {
|
||||||
|
// populate boost carousel
|
||||||
|
|
||||||
// skip dm list for now
|
// skip dm list for now
|
||||||
// public/unified list
|
// public/unified list
|
||||||
const pl = util.$("public_list");
|
const pl = util.$("public_list");
|
||||||
|
@ -149,11 +153,12 @@ export class AdapterElement extends HTMLElement {
|
||||||
const existingThread = document.querySelector(threadSelector);
|
const existingThread = document.querySelector(threadSelector);
|
||||||
const thread = this._threads.find(t=>t.root.data.id == rootId);
|
const thread = this._threads.find(t=>t.root.data.id == rootId);
|
||||||
if (existingThread && thread) {
|
if (existingThread && thread) {
|
||||||
debugger;
|
|
||||||
existingThread.setAttribute("data-latest", `${thread.latest}`);
|
existingThread.setAttribute("data-latest", `${thread.latest}`);
|
||||||
existingThread.setAttribute("data-len", `${thread.messageCount}`);
|
existingThread.setAttribute("data-len", `${thread.messageCount}`);
|
||||||
existingThread.setAttribute("data-new", "true");
|
existingThread.setAttribute("data-new", "true");
|
||||||
} else {
|
} else {
|
||||||
|
// if latest is a boost, put it in the carousel
|
||||||
|
|
||||||
// unified/public list for now
|
// unified/public list for now
|
||||||
const pl = util.$("public_list");
|
const pl = util.$("public_list");
|
||||||
if (pl && thread) {
|
if (pl && thread) {
|
||||||
|
@ -190,14 +195,14 @@ export class AdapterElement extends HTMLElement {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// make multiple passes over the store until every message is either
|
// make multiple passes over the store until every message is either
|
||||||
// placed in a thread, or orphaned and waiting for its parent to be returned
|
// placed in a thread, the boost carousel, or orphaned and waiting for its parent to be returned
|
||||||
do{
|
do{
|
||||||
for (let k of datastore.messages.keys()) {
|
for (let k of datastore.messages.keys()) {
|
||||||
this.placeMsg(k);
|
this.placeMsg(k);
|
||||||
}
|
}
|
||||||
} while (this._threads.reduce((sum: number, thread: MessageThread)=>{
|
} while (this._threads.reduce((sum: number, thread: MessageThread)=>{
|
||||||
return sum + thread.messageCount;
|
return sum + thread.messageCount;
|
||||||
}, 0) + this._orphans.length < datastore.messages.size);
|
}, 0) + this._boosts.length + this._orphans.length < datastore.messages.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
placeMsg(k: string): string | null {
|
placeMsg(k: string): string | null {
|
||||||
|
@ -211,11 +216,20 @@ export class AdapterElement extends HTMLElement {
|
||||||
util.errMsg(`message [${this._name}:${k}] doesn't exist`);
|
util.errMsg(`message [${this._name}:${k}] doesn't exist`);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (msg.renoteId) {
|
||||||
|
// fetch the referent thread and put the boost in the carousel
|
||||||
|
this._convoyBatchTimer.queue(msg.renoteId, 2000);
|
||||||
|
if (!this._boosts.some(m=>m.id == msg.id)) {
|
||||||
|
this._boosts.push(msg);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
for (let t of this._threads) {
|
for (let t of this._threads) {
|
||||||
// avoid processing nodes again on subsequent passes
|
// avoid processing nodes again on subsequent passes
|
||||||
if (!msg || t.findNode(t.root, msg.id)) {
|
if (!msg || t.findNode(t.root, msg.id)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.replyTo) {
|
if (msg.replyTo) {
|
||||||
let x = t.addReply(msg.replyTo, msg);
|
let x = t.addReply(msg.replyTo, msg);
|
||||||
if (x) {
|
if (x) {
|
||||||
|
|
14
frontend/ts/boost-tile-element.ts
Normal file
14
frontend/ts/boost-tile-element.ts
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
export class BoostTileElement extends HTMLElement {
|
||||||
|
|
||||||
|
static observedAttributes = [ "data-boostid", "data-msgid", "data-author", "data-booster" ];
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.innerHTML = "<div class='boost_booster'></div><div class='boost_author'></div><div class='boost_content'></div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
connectedCallback() {
|
||||||
|
}
|
||||||
|
|
||||||
|
attributeChangedCallback(attr: string, prev: string, next: string) {
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ export class Message {
|
||||||
public created: number = 0;
|
public created: number = 0;
|
||||||
public edited: number | null = null;
|
public edited: number | null = null;
|
||||||
public visibility: string = "public";
|
public visibility: string = "public";
|
||||||
|
public renoteId: string | null = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Author {
|
export class Author {
|
||||||
|
|
|
@ -58,13 +58,12 @@ export class DatagramSocket {
|
||||||
}
|
}
|
||||||
|
|
||||||
static connect(): void {
|
static connect(): void {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const wsProto = location.protocol == "https:" ? "wss" : "ws";
|
const wsProto = location.protocol == "https:" ? "wss" : "ws";
|
||||||
const _conn = new WebSocket(`${wsProto}://${location.host}/subscribe`, "underbbs");
|
const _conn = new WebSocket(`${wsProto}://${location.host}/subscribe`, "underbbs");
|
||||||
|
|
||||||
_conn.addEventListener("open", DatagramSocket.onOpen);
|
_conn.addEventListener("open", DatagramSocket.onOpen);
|
||||||
_conn.addEventListener("message", DatagramSocket.onMsg);
|
_conn.addEventListener("message", DatagramSocket.onMsg);
|
||||||
|
|
||||||
_conn.addEventListener("error", (e: any) => {
|
_conn.addEventListener("error", (e: any) => {
|
||||||
console.log("websocket connection error");
|
console.log("websocket connection error");
|
||||||
console.log(JSON.stringify(e));
|
console.log(JSON.stringify(e));
|
||||||
|
|
|
@ -25,6 +25,7 @@ type Message struct {
|
||||||
ReplyCount int `json:"replyCount"`
|
ReplyCount int `json:"replyCount"`
|
||||||
Mentions []string `json:"mentions"`
|
Mentions []string `json:"mentions"`
|
||||||
Visibility string `json:"visibility"`
|
Visibility string `json:"visibility"`
|
||||||
|
RenoteId *string `json:"renoteId,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Author struct {
|
type Author struct {
|
||||||
|
|
|
@ -7,4 +7,6 @@ type Settings struct {
|
||||||
Relays []string `json:"relays",omitempty`
|
Relays []string `json:"relays",omitempty`
|
||||||
Server *string `json:"server",omitempty`
|
Server *string `json:"server",omitempty`
|
||||||
ApiKey *string `json:"apiKey",omitempty`
|
ApiKey *string `json:"apiKey",omitempty`
|
||||||
|
Handle *string `json:"handle",omitempty`
|
||||||
|
Password *string `json:"password",omitempty`
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"hacklab.nilfm.cc/quartzgun/router"
|
"hacklab.nilfm.cc/quartzgun/router"
|
||||||
"hacklab.nilfm.cc/quartzgun/util"
|
"hacklab.nilfm.cc/quartzgun/util"
|
||||||
"html/template"
|
"html/template"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
@ -33,16 +34,14 @@ func getSubscriberByKey(key string, subscribers map[*Subscriber][]adapter.Adapte
|
||||||
|
|
||||||
func setAdaptersForSubscriber(key string, adapters []adapter.Adapter, subscribers map[*Subscriber][]adapter.Adapter) error {
|
func setAdaptersForSubscriber(key string, adapters []adapter.Adapter, subscribers map[*Subscriber][]adapter.Adapter) error {
|
||||||
var ptr *Subscriber = nil
|
var ptr *Subscriber = nil
|
||||||
fmt.Print("looking for subscriber in map..")
|
log.Print("looking for subscriber in map...")
|
||||||
for s, _ := range subscribers {
|
for s, _ := range subscribers {
|
||||||
fmt.Print(".")
|
|
||||||
if s.key == key {
|
if s.key == key {
|
||||||
ptr = s
|
ptr = s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println()
|
|
||||||
if ptr != nil {
|
if ptr != nil {
|
||||||
fmt.Println("setting adaters for the found subscriber: " + ptr.key)
|
log.Print("setting adaters for the found subscriber: " + ptr.key)
|
||||||
subscribers[ptr] = adapters
|
subscribers[ptr] = adapters
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -85,7 +84,7 @@ func apiConfigureAdapters(next http.Handler, subscribers map[*Subscriber][]adapt
|
||||||
break
|
break
|
||||||
|
|
||||||
}
|
}
|
||||||
err := a.Init(s, subscriber.data)
|
err := a.Init(s, &subscriber.data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.AddContextValue(req, "data", err.Error())
|
util.AddContextValue(req, "data", err.Error())
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
|
@ -93,13 +92,13 @@ func apiConfigureAdapters(next http.Handler, subscribers map[*Subscriber][]adapt
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("adapter initialized - subscribing with default filter")
|
log.Print("adapter initialized - subscribing with default filter")
|
||||||
|
|
||||||
errs := a.Subscribe(a.DefaultSubscriptionFilter())
|
errs := a.Subscribe(a.DefaultSubscriptionFilter())
|
||||||
if errs != nil {
|
if errs != nil {
|
||||||
errMsg := ""
|
errMsg := ""
|
||||||
for _, e := range errs {
|
for _, e := range errs {
|
||||||
fmt.Println("processing an error")
|
log.Print("processing an error")
|
||||||
errMsg += fmt.Sprintf("- %s\n", e.Error())
|
errMsg += fmt.Sprintf("- %s\n", e.Error())
|
||||||
}
|
}
|
||||||
util.AddContextValue(req, "data", errMsg)
|
util.AddContextValue(req, "data", errMsg)
|
||||||
|
@ -108,10 +107,10 @@ func apiConfigureAdapters(next http.Handler, subscribers map[*Subscriber][]adapt
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("adapter ready for use; adding to array")
|
log.Print("adapter ready for use; adding to array")
|
||||||
|
|
||||||
adapters = append(adapters, a)
|
adapters = append(adapters, a)
|
||||||
fmt.Println("adapter added to array")
|
log.Print("adapter added to array")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: cancel subscriptions on any existing adapters
|
// TODO: cancel subscriptions on any existing adapters
|
||||||
|
@ -169,7 +168,7 @@ func apiAdapterFetch(next http.Handler, subscribers map[*Subscriber][]adapter.Ad
|
||||||
if a.Name() == apiParams["adapter_id"] {
|
if a.Name() == apiParams["adapter_id"] {
|
||||||
err := a.Fetch(queryParams["entity_type"][0], queryParams["entity_id"])
|
err := a.Fetch(queryParams["entity_type"][0], queryParams["entity_id"])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error())
|
log.Print(err.Error())
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
} else {
|
} else {
|
||||||
w.WriteHeader(http.StatusAccepted)
|
w.WriteHeader(http.StatusAccepted)
|
||||||
|
|
|
@ -3,7 +3,6 @@ package server
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"forge.lightcrystal.systems/lightcrystal/underbbs/adapter"
|
"forge.lightcrystal.systems/lightcrystal/underbbs/adapter"
|
||||||
"forge.lightcrystal.systems/lightcrystal/underbbs/models"
|
"forge.lightcrystal.systems/lightcrystal/underbbs/models"
|
||||||
"golang.org/x/time/rate"
|
"golang.org/x/time/rate"
|
||||||
|
@ -90,14 +89,14 @@ func (self *BBSServer) subscribeHandler(w http.ResponseWriter, r *http.Request)
|
||||||
defer c.Close(websocket.StatusInternalError, "")
|
defer c.Close(websocket.StatusInternalError, "")
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
fmt.Println("waiting for data on the subscriber's channel")
|
self.logf("waiting for data on the subscriber's channel")
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case msg := <-s.msgs:
|
case msg := <-s.msgs:
|
||||||
writeTimeout(ctx, time.Second*5, c, msg)
|
writeTimeout(ctx, time.Second*5, c, msg)
|
||||||
|
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
fmt.Println("subscriber has disconnected")
|
self.logf("subscriber has disconnected")
|
||||||
close(s.data)
|
close(s.data)
|
||||||
return //ctx.Err()
|
return //ctx.Err()
|
||||||
}
|
}
|
||||||
|
@ -110,7 +109,7 @@ func (self *BBSServer) subscribeHandler(w http.ResponseWriter, r *http.Request)
|
||||||
// block on the data channel, serializing and passing the data to the subscriber
|
// block on the data channel, serializing and passing the data to the subscriber
|
||||||
listen([]chan models.SocketData{s.data}, s.msgs)
|
listen([]chan models.SocketData{s.data}, s.msgs)
|
||||||
|
|
||||||
fmt.Println("data listener is done!")
|
self.logf("data listener is done!")
|
||||||
|
|
||||||
if errors.Is(err, context.Canceled) {
|
if errors.Is(err, context.Canceled) {
|
||||||
return
|
return
|
||||||
|
|
25
underbbs.go
25
underbbs.go
|
@ -2,25 +2,44 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"forge.lightcrystal.systems/lightcrystal/underbbs/cli"
|
||||||
"forge.lightcrystal.systems/lightcrystal/underbbs/server"
|
"forge.lightcrystal.systems/lightcrystal/underbbs/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
err := run()
|
|
||||||
|
args := os.Args
|
||||||
|
|
||||||
|
var err error = nil
|
||||||
|
|
||||||
|
progname := filepath.Base(args[0])
|
||||||
|
switch progname {
|
||||||
|
case "underbbs-cli":
|
||||||
|
err = run_cli(args[1:]...)
|
||||||
|
default:
|
||||||
|
err = run_srvr()
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
fmt.Println(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func run() error {
|
func run_cli(args ...string) error {
|
||||||
|
return cli.Process(args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func run_srvr() error {
|
||||||
l, err := net.Listen("tcp", ":"+strconv.FormatInt(int64(9090), 10))
|
l, err := net.Listen("tcp", ":"+strconv.FormatInt(int64(9090), 10))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue