Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ require (
)

require (
github.com/reiver/go-actsock v0.0.0-20250528050037-fdd924639ca2
github.com/reiver/go-actsock v0.0.0-20250529230157-8f2644949176
github.com/reiver/go-etag v0.0.0-20241130123934-1a98d29fda6e
github.com/reiver/go-fediverseid v0.0.0-20250403113622-694e7caca2d7
github.com/reiver/go-http400 v0.0.0-20250528125814-c9872b77629f
github.com/reiver/go-http500 v0.0.0-20250331114301-bf7c804c79ea
github.com/reiver/go-jsonld v0.0.0-20241216235649-e851bd7e3ab6
)

require (
github.com/reiver/go-json v0.0.0-20250330153804-8f52e0beba6c // indirect
github.com/reiver/go-json v0.0.0-20250529225843-4e6beb4c28e8 // indirect
github.com/reiver/go-lck v0.0.0-20240808133902-b56df221c39f // indirect
github.com/reiver/go-opt v0.0.0-20240809035328-1ff08dec9bc4 // indirect
)
12 changes: 8 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/reiver/go-actsock v0.0.0-20250528050037-fdd924639ca2 h1:Yco1oShkFSf6RQcbOiprDYplxJhLs5xezsM5T2nFpaI=
github.com/reiver/go-actsock v0.0.0-20250528050037-fdd924639ca2/go.mod h1:TOyU/UeNZE1Ehp+xppk/Wt+9bKIKM5hG8c5ptIMPzoI=
github.com/reiver/go-actsock v0.0.0-20250529230157-8f2644949176 h1:zqndmiya01uH75kPhnpkCmSJo7ig+rg6BQeICdEXjc8=
github.com/reiver/go-actsock v0.0.0-20250529230157-8f2644949176/go.mod h1:B4qy0o3N26iO7nPfD36TQZPdHWo7y+G2MmXQCmqLfTM=
github.com/reiver/go-erorr v0.0.0-20240801233437-8cbde6d1fa3f h1:D1QSxKHm8U73XhjsW3SFLkT0zT5pKJi+1KGboMhY1Rk=
github.com/reiver/go-erorr v0.0.0-20240801233437-8cbde6d1fa3f/go.mod h1:F0HbBf+Ak2ZlE8YkDW4Y+KxaUmT0KaaIJK6CXY3cJxE=
github.com/reiver/go-etag v0.0.0-20241130123934-1a98d29fda6e h1:2FJeuK9Uc6BGLnXz4QOyfPefILfXGoPxiyCpgwz0WMU=
github.com/reiver/go-etag v0.0.0-20241130123934-1a98d29fda6e/go.mod h1:TGoPFV3b4+PE2rF27XiFZLu6dg4faIEx7AUITCKyj4c=
github.com/reiver/go-fediverseid v0.0.0-20250403113622-694e7caca2d7 h1:Hihr6cb93jDa1JkdGnzW8t8opmGQBvq1IZFiOcHQnFs=
github.com/reiver/go-fediverseid v0.0.0-20250403113622-694e7caca2d7/go.mod h1:c2iT0wQYBegVeWsC8D9SCLgQgRRlP0q0WQYvbdcLH3A=
github.com/reiver/go-json v0.0.0-20250330153804-8f52e0beba6c h1:ieAQj7AfGOq3g4s5tYB1wyib8DIPr3PG4Z88g5bJMVE=
github.com/reiver/go-json v0.0.0-20250330153804-8f52e0beba6c/go.mod h1:ns4kpzbK+OyMUZYT8UmBxrsYWNmvB/irZGmyIh99cxY=
github.com/reiver/go-http400 v0.0.0-20250528125814-c9872b77629f h1:HYwyot06pIjhAPUBbYP8L4aUSeM/4q8b97c3Pfq2xEo=
github.com/reiver/go-http400 v0.0.0-20250528125814-c9872b77629f/go.mod h1:x9w6wkwDkUAlagyX340F4mUFLOILDP2p2svNpeooLdk=
github.com/reiver/go-http500 v0.0.0-20250331114301-bf7c804c79ea h1:wwQj6mPCCI3iO+K7tCOOC+W7mumuQ2o7sRPS91tgzPQ=
github.com/reiver/go-http500 v0.0.0-20250331114301-bf7c804c79ea/go.mod h1:n5g92CfMaJKAFuJ6gkWS9UgAiQJxsUNoLe15U7RWtpI=
github.com/reiver/go-json v0.0.0-20250529225843-4e6beb4c28e8 h1:42KV3+ahH6k9kAUCx3EDWYZ3ftZQqhL8yepel17J0tU=
github.com/reiver/go-json v0.0.0-20250529225843-4e6beb4c28e8/go.mod h1:ns4kpzbK+OyMUZYT8UmBxrsYWNmvB/irZGmyIh99cxY=
github.com/reiver/go-jsonld v0.0.0-20241216235649-e851bd7e3ab6 h1:TSKZsxbubNUfECSRpiePBIyJwe4ak0XCC1HNHC5Wsns=
github.com/reiver/go-jsonld v0.0.0-20241216235649-e851bd7e3ab6/go.mod h1:sE1mTJZa0fGhHDlpATNcVNAzuCnvtUxahVSGkYjz0r4=
github.com/reiver/go-lck v0.0.0-20240808133902-b56df221c39f h1:KBVWBoNIM8mHkUR3dP64hm2p2vxoD5xHZ6wUllCjFTc=
Expand Down
File renamed without changes.
File renamed without changes.
138 changes: 138 additions & 0 deletions www/ACCT/conf/servehttp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package verboten

import (
"fmt"
"io"
"net/http"

"github.com/gorilla/websocket"
"github.com/reiver/go-actsock"
"github.com/reiver/go-fediverseid"
"github.com/reiver/go-http400"
"github.com/reiver/go-http500"

"github.com/reiver/logjam/srv/http"
"github.com/reiver/logjam/srv/websock"
)

const acct string = "acct"

const path string = "/{"+acct+"}/conf"

func init() {
httpsrv.Router.HandleFunc(path, ServeHTTP).Methods(http.MethodGet, http.MethodOptions)
}

func ServeHTTP(responsewriter http.ResponseWriter, request *http.Request) {
if nil == responsewriter {
log.Error("nil response-writer")
return
}
if nil == request {
http500.InternalServerError(responsewriter, request)
log.Error("nil request")
return
}

responsewriter.Header().Add("Access-Control-Allow-Origin", "*")

var account string
{
vars := httpsrv.Vars(request)
if 0 < len(vars) {
account = vars[acct]
}

// For backwards compatibility reasons.
// Can remove later.
if "" == account {
account = request.URL.Query().Get("room")
}

if "" == account {
http400.BadRequest(responsewriter, request)
log.Debugf("HTTP Bad Request — acct == %q", account)
return
}

log.Debugf("account (fediverse-id): %q", account)
}

switch {
case websocket.IsWebSocketUpgrade(request):
wsConn, err := upgrader.Upgrade(responsewriter, request, nil)
if nil != err {
log.Errorf("problem upgrading to websocket: %s", err)
return
}

socketID, err := websocksrv.WebSockSrv.OnConnect(wsConn)
if nil != err {
log.Errorf("problem on-connecting websocket: %s", err)
_ = wsConn.Close()
return
}

roomID := account
go serveWS(wsConn, socketID, roomID)

default:
serveHTTP(responsewriter, request, account)
return
}
}

func serveHTTP(responsewriter http.ResponseWriter, request *http.Request, account string) {
if nil == responsewriter {
log.Error("nil response-writer")
return
}
if nil == request {
http500.InternalServerError(responsewriter, request)
log.Error("nil request")
return
}
if nil == request.URL {
http500.InternalServerError(responsewriter, request)
log.Error("nil request-url")
return
}

var acctURI string
{
fediverseID, err := fediverseid.ParseFediverseIDString(account)
if nil != err {
http400.BadRequest(responsewriter, request)
log.Debugf("HTTP Bad Request — bad account — acct == %q: %s", account, err)
return
}

acctURI = fediverseID.AcctURI()
}

var id string
var inoutbox string
{
var uri = *request.URL
uri.User = nil
uri.Scheme = "https"
uri.Host = request.Host

id = uri.String()

uri.Scheme = "wss"
inoutbox = uri.String()
}

var object = actsock.Conference{
Actor: acctURI,
EndPoints: map[string]string{
"inoutbox":inoutbox,
},
ID: id,
Name: fmt.Sprintf("%s — GreatApe", account),
}

responsewriter.Header().Set("Content-Type", "application/activity+json")
io.WriteString(responsewriter, object.String())
}
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions www/ACCT/import.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package verboten

import (
_ "github.com/reiver/logjam/www/ACCT/conf"
)
35 changes: 2 additions & 33 deletions www/hapi/v1/ws/servehttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,11 @@ import (
"net/http"

"github.com/reiver/logjam/srv/http"
"github.com/reiver/logjam/srv/websock"
tempTODO "github.com/reiver/logjam/www/ACCT/conf"
)

const path string = "/hapi/v1/ws"

func init() {
httpsrv.Router.HandleFunc(path, serveHTTP).Methods(http.MethodGet, http.MethodOptions)
}

func serveHTTP(responsewriter http.ResponseWriter, request *http.Request) {
if nil == responsewriter {
log.Error("nil response-writer")
return
}
if nil == request {
const code int = http.StatusInternalServerError
http.Error(responsewriter, http.StatusText(code), code)
log.Error("nil request")
return
}

responsewriter.Header().Add("Access-Control-Allow-Origin", "*")

wsConn, err := upgrader.Upgrade(responsewriter, request, nil)
if nil != err {
log.Errorf("problem upgrading to websocket: %s", err)
return
}
socketID, err := websocksrv.WebSockSrv.OnConnect(wsConn)
if nil != err {
log.Errorf("problem on-connecting websocket: %s", err)
_ = wsConn.Close()
return
}

roomID := request.URL.Query().Get("room")
log.Debugf("room-id (fediverse-id): %q", roomID)
go serveWS(wsConn, socketID, roomID)
httpsrv.Router.HandleFunc(path, tempTODO.ServeHTTP).Methods(http.MethodGet, http.MethodOptions)
}
1 change: 1 addition & 0 deletions www/import.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package verboten

import (
_ "github.com/reiver/logjam/www/ACCT"
_ "github.com/reiver/logjam/www/favicon"
_ "github.com/reiver/logjam/www/goldgorilla"
_ "github.com/reiver/logjam/www/hapi"
Expand Down