This repository has been archived by the owner on Dec 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
163 changed files
with
8,452 additions
and
2,792 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
__pycache__/ | ||
|
||
*.env | ||
*.env | ||
|
||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,8 @@ | ||
|
||
![](./branding/server%20banner.svg) | ||
# Server | ||
Official source code of the Meower server, written in Python. Powered by CloudLink. | ||
|
||
## Running | ||
```py | ||
git clone https://github.com/meower-media/server.git --recursive | ||
cd Meower-Server | ||
cd Meower-Server | ||
pip install -r requirements.txt | ||
|
||
cp .env.example .env | ||
|
||
# edit env files | ||
|
||
python3 main.py | ||
``` | ||
the go stuff, in cmd/* and pkg/* has no security features, so be careful!!! | ||
|
||
## API docs | ||
See [the autogenerated documentation](https://api.meower.org/docs) and the [Meower documentation](https://docs.meower.org) | ||
this branch is the subject of a major rewrite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ As of Feb. 7th, 2023, the currently deployed server version is built upon Cloudl | |
If you believe that your data on any Meower Media products/services has been compromised, please contact an administrator of Meower Media directly, or contact [email protected] immediately. From which, Meower Media will review your report in a timely fashion, and determine suitable course of action. | ||
|
||
## Reporting a security vulnerability | ||
If you believe you have discovered a security vulnerability, please report it to Meower Media through coordinated disclosure. To report a security vulnerability, [please do so here](https://github.com/meower-media-co/Meower-Server/security/advisories/new). If you have questions about whether an issue is a security vulnerability, please contact Meower Media at [email protected]. | ||
If you believe you have discovered a security vulnerability, please report it to Meower Media through coordinated disclosure. To report a security vulnerability, [please do so here](https://github.com/meower-media/Meower-Server/security/advisories/new). If you have questions about whether an issue is a security vulnerability, please contact Meower Media at [email protected]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"os" | ||
|
||
"github.com/getsentry/sentry-go" | ||
"github.com/joho/godotenv" | ||
"github.com/meower-media/server/pkg/api/events" | ||
) | ||
|
||
func main() { | ||
// Load dotenv | ||
godotenv.Load() | ||
|
||
// Initialise Sentry | ||
sentry.Init(sentry.ClientOptions{ | ||
Dsn: os.Getenv("EVENTS_SENTRY_DSN"), | ||
}) | ||
|
||
// Get expose address | ||
exposeAddr := os.Getenv("EVENTS_ADDRESS") | ||
if exposeAddr == "" { | ||
exposeAddr = ":3000" | ||
} | ||
|
||
// Create & run server | ||
server := events.NewServer() | ||
err := server.Run(exposeAddr) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,49 @@ | ||
# Load .env file | ||
from dotenv import load_dotenv | ||
load_dotenv() | ||
|
||
import asyncio | ||
import os | ||
import uvicorn | ||
import sentry_sdk | ||
|
||
from threading import Thread | ||
|
||
from cloudlink import CloudlinkServer | ||
from supporter import Supporter | ||
from security import background_tasks_loop | ||
from grpc_auth import service as grpc_auth | ||
from rest_api import app as rest_api | ||
|
||
|
||
if __name__ == "__main__": | ||
# Initialise Sentry (uses SENTRY_DSN env var) | ||
sentry_sdk.init() | ||
|
||
# Create Cloudlink server | ||
cl = CloudlinkServer() | ||
|
||
# Create Supporter class | ||
supporter = Supporter(cl) | ||
cl.supporter = supporter | ||
|
||
# Start background tasks loop | ||
Thread(target=background_tasks_loop, daemon=True).start() | ||
|
||
# Start gRPC services | ||
Thread(target=grpc_auth.serve, daemon=True).start() | ||
|
||
# Initialise REST API | ||
rest_api.cl = cl | ||
rest_api.supporter = supporter | ||
|
||
# Start REST API | ||
Thread(target=uvicorn.run, args=(rest_api,), kwargs={ | ||
"host": os.getenv("API_HOST", "0.0.0.0"), | ||
"port": int(os.getenv("API_PORT", 3001)), | ||
"root_path": os.getenv("API_ROOT", "") | ||
}, daemon=True).start() | ||
|
||
# Start Cloudlink server | ||
asyncio.run(cl.run(host=os.getenv("CL3_HOST", "0.0.0.0"), port=int(os.getenv("CL3_PORT", 3000)))) | ||
# Load .env file | ||
from dotenv import load_dotenv | ||
load_dotenv() | ||
|
||
import os, sys, asyncio, uvicorn, sentry_sdk | ||
from threading import Thread | ||
|
||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../pkg/legacy'))) | ||
|
||
from cloudlink import CloudlinkServer | ||
from supporter import Supporter | ||
from security import background_tasks_loop | ||
from grpc_auth import service as grpc_auth | ||
from rest_api import app as rest_api | ||
from events import events | ||
|
||
|
||
if __name__ == "__main__": | ||
# Initialise Sentry (uses SENTRY_DSN env var) | ||
sentry_sdk.init() | ||
|
||
# Create Cloudlink server | ||
cl = CloudlinkServer() | ||
|
||
# Create Supporter class | ||
supporter = Supporter(cl) | ||
cl.supporter = supporter | ||
|
||
events.add_supporter(supporter) | ||
|
||
# Start background tasks loop | ||
Thread(target=background_tasks_loop, daemon=True).start() | ||
|
||
# Start gRPC services | ||
Thread(target=grpc_auth.serve, daemon=True).start() | ||
|
||
# Initialise REST API | ||
rest_api.cl = cl | ||
rest_api.supporter = supporter | ||
|
||
# Start REST API | ||
#Thread(target=uvicorn.run, args=(rest_api,), kwargs={ | ||
# "host": os.getenv("API_HOST", "0.0.0.0"), | ||
# "port": int(os.getenv("API_PORT", 3001)), | ||
# "root_path": os.getenv("API_ROOT", "") | ||
#}, daemon=True).start() | ||
|
||
# Start Cloudlink server | ||
asyncio.run(cl.run(host=os.getenv("CL3_HOST", "0.0.0.0"), port=int(os.getenv("CL3_PORT", 3000)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"net/http" | ||
"os" | ||
"time" | ||
|
||
"github.com/getsentry/sentry-go" | ||
"github.com/joho/godotenv" | ||
"github.com/meower-media/server/pkg/api/rest" | ||
"github.com/meower-media/server/pkg/db" | ||
"github.com/meower-media/server/pkg/emails" | ||
"github.com/meower-media/server/pkg/meowid" | ||
"github.com/meower-media/server/pkg/rdb" | ||
"github.com/meower-media/server/pkg/users" | ||
) | ||
|
||
func main() { | ||
// Load dotenv | ||
godotenv.Load() | ||
|
||
// Init Sentry | ||
if err := sentry.Init(sentry.ClientOptions{ | ||
Dsn: os.Getenv("SENTRY_DSN"), | ||
}); err != nil { | ||
panic(err) | ||
} | ||
|
||
// Init MeowID | ||
if err := meowid.Init(os.Getenv("NODE_ID")); err != nil { | ||
panic(err) | ||
} | ||
|
||
// Init MongoDB | ||
if err := db.Init(os.Getenv("MONGO_URI"), os.Getenv("MONGO_DB")); err != nil { | ||
panic(err) | ||
} | ||
|
||
// Init Redis | ||
if err := rdb.Init(os.Getenv("REDIS_URI")); err != nil { | ||
panic(err) | ||
} | ||
|
||
// Init token signing keys | ||
if err := users.InitTokenSigningKeys(); err != nil { | ||
panic(err) | ||
} | ||
|
||
// Send test email | ||
emails.SendEmail("verify", "Tnix", "[email protected]", "abc123") | ||
|
||
// Serve HTTP router | ||
port := os.Getenv("HTTP_PORT") | ||
if port == "" { | ||
port = "3000" | ||
} | ||
log.Println("Serving HTTP server on :" + port) | ||
http.ListenAndServe(":"+port, rest.Router()) | ||
|
||
// Wait for Sentry events to flush | ||
sentry.Flush(time.Second * 5) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module github.com/meower-media/server | ||
|
||
go 1.22.5 | ||
|
||
require ( | ||
github.com/getsentry/sentry-go v0.28.1 | ||
github.com/go-chi/chi/v5 v5.1.0 | ||
github.com/go-playground/validator/v10 v10.11.1 | ||
github.com/gorilla/websocket v1.5.3 | ||
github.com/joho/godotenv v1.5.1 | ||
github.com/pquerna/otp v1.4.0 | ||
github.com/redis/go-redis/v9 v9.6.1 | ||
github.com/rs/cors v1.11.1 | ||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e | ||
github.com/vmihailenco/msgpack/v5 v5.3.5 | ||
github.com/yl2chen/cidranger v1.0.2 | ||
go.mongodb.org/mongo-driver v1.16.1 | ||
golang.org/x/crypto v0.22.0 | ||
gopkg.in/mail.v2 v2.3.1 | ||
) | ||
|
||
require ( | ||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect | ||
github.com/cespare/xxhash/v2 v2.2.0 // indirect | ||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect | ||
github.com/go-playground/locales v0.14.0 // indirect | ||
github.com/go-playground/universal-translator v0.18.0 // indirect | ||
github.com/golang/snappy v0.0.4 // indirect | ||
github.com/klauspost/compress v1.17.7 // indirect | ||
github.com/leodido/go-urn v1.2.1 // indirect | ||
github.com/montanaflynn/stats v0.7.1 // indirect | ||
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect | ||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect | ||
github.com/xdg-go/scram v1.1.2 // indirect | ||
github.com/xdg-go/stringprep v1.0.4 // indirect | ||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect | ||
golang.org/x/sync v0.7.0 // indirect | ||
golang.org/x/sys v0.19.0 // indirect | ||
golang.org/x/text v0.14.0 // indirect | ||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect | ||
) |
Oops, something went wrong.