Self hosted live chat server written in Go

goch

Build Status codecov Go Report Card Maintainability

goch is a self-hosted live-chat server written in Go.

It allows you to run a live-chat software on your own infrastructure.

You can create multiple private and public chatrooms where two or more users can be at the same time.

For communication, it uses RESTful endpoints, Websockets, NATS Streaming, and Redis.

Goch is a fork of Gossip, with many added features and fixes.

Getting started

To run goch locally, you need docker, docker-compose and go installed and set on your path. After downloading/cloning the project, run ./up which compiles the binary and runs docker-compose with goch, NATS Streaming, and Redis. If there were no errors, goch should be running on localhost (port 8080).

How it works

In order for the server to run, ADMIN_USERNAME and ADMIN_PASSWORD env variables have to be set. In the repository, they are set to admin and pass respectively, but you should obviously change those for security reasons.

Once the server is running, the following routes are available:

  • POST /admin/channels: Creates a new channel. You have to provide a unique name for a channel (usually an ID), and the response includes channel's secret which will be used for connecting to channel later on. This endpoint should be invoked server-side with provided admin credentials. The response should be saved in order to connect to the channel later on.

  • POST /register: Register a user in a channel. In order to register for the channel, a UID, DisplayName, ChannelSecret, and ChannelName needs to be provided. Optionally user secret needs to be provided, but if not the server will generate and return one.

  • GET /connect: Connects to a chat and returns a WebSocket connection, along with chat history. Channel, UID, and Secret need to be provided. Optionally LastSeq is provided which will return chat history only after LastSeq (UNIX timestamp).

The remaining routes are only used as 'helpers':

  • GET /channels/{name}?secret=$SECRET: Returns list of members in a channel. Channel name has to be provided as URL param and channel secret as a query param.

  • GET /admin/channels: Returns list of all available channels.

  • GET /admin/channels/{name}/user/{uid}: Returns list of unread messages on a chat for a user.

License

goch is licensed under the MIT license. Check the LICENSE file for details.

Author

Emir Ribic

Comments
  • Can't reach this on the localhost:8080

    Can't reach this on the localhost:8080

    I'm just getting started with Golang. This looks great.

    Just wondering if you could point into the right direction. I can't reach this on the localhost:8080

    Issue below with go command not found, is it referring to the line 2 in the up file? Appreciate the time.

    ./up: 2: ./up: go: not found

    GOOS=linux CGO_ENABLED=0 go build -o goch .

    sudo ./up ./up: 2: ./up: go: not found Starting goch... Building goch Step 1/4 : FROM yikaus/alpine-bash ---> c98c656004a8 Step 2/4 : RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/* ---> Using cache ---> 1d178928b654 Step 3/4 : ADD goch / ---> Using cache ---> 59f910a90085 Step 4/4 : ENTRYPOINT /goch ---> Using cache ---> 9d683bad10c7 Successfully built 9d683bad10c7 Successfully tagged goch_goch:latest Starting goch_nats_stream_1 ... done Starting goch_redis_1 ... done Starting goch_goch_1 ... done Attaching to goch_redis_1, goch_nats_stream_1, goch_goch_1 redis_1 | 1:C 27 May 2020 04:50:36.126 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo redis_1 | 1:C 27 May 2020 04:50:36.126 # Redis version=6.0.3, bits=64, commit=00000000, modified=0, pid=1, just started nats_stream_1 | [1] 2020/05/27 04:50:36.194234 [INF] STREAM: Starting nats-streaming-server[test-cluster] version 0.17.0 nats_stream_1 | [1] 2020/05/27 04:50:36.194270 [INF] STREAM: ServerID: nGTtYw76Q6tSdgCXY6WexD nats_stream_1 | [1] 2020/05/27 04:50:36.194276 [INF] STREAM: Go version: go1.13.7 nats_stream_1 | [1] 2020/05/27 04:50:36.194281 [INF] STREAM: Git commit: [f4b7190] nats_stream_1 | [1] 2020/05/27 04:50:36.195443 [INF] Starting nats-server version 2.1.4 nats_stream_1 | [1] 2020/05/27 04:50:36.195461 [INF] Git commit [fb009af] nats_stream_1 | [1] 2020/05/27 04:50:36.195846 [INF] Starting http monitor on 0.0.0.0:8222 nats_stream_1 | [1] 2020/05/27 04:50:36.195925 [INF] Listening for client connections on 0.0.0.0:4222 nats_stream_1 | [1] 2020/05/27 04:50:36.195931 [INF] Server id is NCXIXTJAGO6NTMRMBNHX37YKLQWM4LRPFRTYHU7R57FKTVAYUNTMEH7B nats_stream_1 | [1] 2020/05/27 04:50:36.195934 [INF] Server is ready redis_1 | 1:C 27 May 2020 04:50:36.126 # Configuration loaded nats_stream_1 | [1] 2020/05/27 04:50:36.223499 [INF] STREAM: Recovering the state... redis_1 | 1:M 27 May 2020 04:50:36.128 * Running mode=standalone, port=6379. redis_1 | 1:M 27 May 2020 04:50:36.129 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. redis_1 | 1:M 27 May 2020 04:50:36.129 # Server initialized nats_stream_1 | [1] 2020/05/27 04:50:36.224485 [INF] STREAM: Recovered 0 channel(s) redis_1 | 1:M 27 May 2020 04:50:36.129 * Ready to accept connections nats_stream_1 | [1] 2020/05/27 04:50:36.474956 [INF] STREAM: Message store is FILE nats_stream_1 | [1] 2020/05/27 04:50:36.474974 [INF] STREAM: Store location: data nats_stream_1 | [1] 2020/05/27 04:50:36.475007 [INF] STREAM: ---------- Store Limits ---------- nats_stream_1 | [1] 2020/05/27 04:50:36.475012 [INF] STREAM: Channels: unlimited nats_stream_1 | [1] 2020/05/27 04:50:36.475016 [INF] STREAM: --------- Channels Limits -------- nats_stream_1 | [1] 2020/05/27 04:50:36.475019 [INF] STREAM: Subscriptions: 1000 * nats_stream_1 | [1] 2020/05/27 04:50:36.475022 [INF] STREAM: Messages : 1000000 * nats_stream_1 | [1] 2020/05/27 04:50:36.475025 [INF] STREAM: Bytes : 976.56 MB * nats_stream_1 | [1] 2020/05/27 04:50:36.475029 [INF] STREAM: Age : unlimited * nats_stream_1 | [1] 2020/05/27 04:50:36.475031 [INF] STREAM: Inactivity : unlimited * nats_stream_1 | [1] 2020/05/27 04:50:36.475035 [INF] STREAM: ---------------------------------- nats_stream_1 | [1] 2020/05/27 04:50:36.475039 [INF] STREAM: Streaming Server is ready goch_1 | 2020/05/27 04:50:37 starting server on port:8080

  • Go module support request

    Go module support request

    With go mod support, you can:

    • eliminate /vendor
    • successfully run ./up without having to adjust any Go envs, since dependencies will be installed by default to users' GOPATH

    To convert to go modules from Gopkg:

    cd goch
    go mod init
    go get
    

    Running go mod init will create a go.mod file. Running go get will generate your go.sum file.

    With those, you can safely get rid of:

    • /vendor
    • Gopkg.lock
    • Gopkg.toml
  • Missing .env file?

    Missing .env file?

    Tried to follow your setup instructions to run locally, but I get this issue when running the docker compose command:

    > docker-compose up --build
    ERROR: Couldn't find env file: MY_GOPATH\src\github.com\ribice\goch\.env
    

    I see that .env is in the .gitignore file, but referenced in the docker-compose.yml file, I am just wondering if that is the issue or if I am missing something.

    Thank you for your help! Very excited to check out your project!

  • Is this still under development?

    Is this still under development?

    The architecture of the project was good, except that I didn't run it properly, and there were a lot of bugs.Still hope the author can add a test example

  • Allow connecting to more than one chat simultaneously

    Allow connecting to more than one chat simultaneously

    Currently you can have only one chat per websocket connection.

    This is limited in internal/agent/agent.go where Agent struct holds single Chat.

    On client, this currently works by connecting to new chat and disconnecting from previous one each time a different chat is clicked. But this prevents getting messages from other chats, although you can still show number of unread messages by invoking the unread count endpoint.

  • Rewrite client

    Rewrite client

    The static client for gossip (pre-fork version) is available here.

    The endpoints are different now (most changed from POST to GET and from JSON body to URL/Query params).

    Other than that it should be straightforward.

    The React chat component should be able to hook without changes to the modified client.

Simple TCP-based chat server

hub-server Simple TCP-based chat server. Client can be found: https://github.com/alankritjoshi/hub-client Setup go run server.go 1234 How it works Use

Oct 25, 2021
Open-IM-Server is open source instant messaging Server.Backend in Go.
Open-IM-Server is open source instant messaging Server.Backend in Go.

Open-IM-Server is open source instant messaging Server.Backend in Go.

Dec 31, 2022
Scalable real-time messaging server in language-agnostic way
Scalable real-time messaging server in language-agnostic way

Centrifugo is a scalable real-time messaging server in language-agnostic way. Centrifugo works in conjunction with application backend written in any

Jan 1, 2023
Instant messaging server for the Extensible Messaging and Presence Protocol (XMPP).
Instant messaging server for the Extensible Messaging and Presence Protocol (XMPP).

Instant messaging server for the Extensible Messaging and Presence Protocol (XMPP).

Dec 31, 2022
A simple server for sending and receiving messages in real-time per WebSocket. (Includes a sleek web-ui)
A simple server for sending and receiving messages in real-time per WebSocket. (Includes a sleek web-ui)

A simple server for sending and receiving messages in real-time per WebSocket. (Includes a sleek web-ui)

Jan 9, 2023
IRC bot written in Go

GoRobot Yet Another IRC robot. Features: Multiple servers, multiple channels, conversations, flood control Administration via a specific set of IRC ch

Sep 26, 2019
ircflu is an IRC bot written in Go

ircflu ircflu is an IRC bot written in Go with a flexible message- & command-handler. Among its advanced features are a cat-server which allows you to

Apr 26, 2021
GoatCounter is an open source web analytics platform available as a hosted service or self-hosted app

GoatCounter is an open source web analytics platform available as a hosted service (free for non-commercial use) or self-hosted app. It aims to offer easy to use and meaningful privacy-friendly web analytics as an alternative to Google Analytics or Matomo.

Dec 29, 2022
Instant, disposable, single-binary web based live chat server. Go + VueJS.
Instant, disposable, single-binary web based live chat server. Go + VueJS.

Niltalk Niltalk is a web based disposable chat server. It allows users to create password protected disposable, ephemeral chatrooms and invite peers t

Jan 4, 2023
Headscale - An open source, self-hosted implementation of the Tailscale control server

Headscale - An open source, self-hosted implementation of the Tailscale control server

Dec 29, 2022
Self-hosted music streaming server 🎶 with RESTful API and Web interface
Self-hosted music streaming server 🎶 with RESTful API and Web interface

Self-hosted music streaming server ?? with RESTful API and Web interface. Think of it as your very own Spotify!

Dec 27, 2022
cert-manager webhook & CoreDNS plugin for solving DNS01 challenge on self-hosted authoritative DNS server.
cert-manager webhook & CoreDNS plugin for solving DNS01 challenge on self-hosted authoritative DNS server.

cert-manager webhook & CoreDNS plugin This repo exists for a niche case scenario in which we are running cert-manager on one or multiple Kubernetes cl

Feb 4, 2022
A tasty, self-hosted Git server for the command line🍦
A tasty, self-hosted Git server for the command line🍦

Soft Serve A tasty, self-hosted Git server for the command line. ?? Configure with git Create repos on demand with git push Browse repos with an SSH-a

Jan 9, 2023
go-chat is a gRPC based chat CLI written in golang for command line lovers
go-chat is a gRPC based chat CLI written in golang for command line lovers

go-chat go-chat is a gRPC based chat CLI written in golang for command line lovers. This CLI allows you to chat with your friends without leaving the

Oct 14, 2022
Go-random-chat - Fast and scalable real-time random chat written in go
Go-random-chat - Fast and scalable real-time random chat written in go

Go Random Chat Fast and scalable real-time random chat written in go. Features:

Dec 21, 2022
🖖🏻 A self-hosted Quora like web application written in Go
🖖🏻 A self-hosted Quora like web application written in Go

Guora ???? A self-hosted Quora like web application written in Go 基于 Golang 类似知乎的私有部署问答应用 包含问答、评论、点赞、管理后台等功能 Quick Start (Docker Deploy) $ docker-comp

Dec 27, 2022
Cloud torrent: a self-hosted remote torrent client, written in Go (golang)
Cloud torrent: a self-hosted remote torrent client, written in Go (golang)

Cloud torrent is a a self-hosted remote torrent client, written in Go (golang).

Dec 21, 2021
Take control over your live stream video by running it yourself. Streaming + chat out of the box.
Take control over your live stream video by running it yourself.  Streaming + chat out of the box.

Take control over your content and stream it yourself. Explore the docs » View Demo · Use Our Server for Testing · FAQ · Report Bug Table of Contents

Jan 1, 2023
🚀 Get Youtube Live stream chat feed without any authentication!

youtube-live-chat-downloader Fetches Youtube live chat messages with no authentication required. How does it work? The request for fetching live chat

Oct 17, 2022