rtcchat2

package module
v0.0.0-...-511b4bd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2020 License: MIT Imports: 17 Imported by: 0

README

rtc chat v2

A WebRTC chat service written in Go

rtc chat establishes end-to-end encrypted, P2P and relayed communication links.

Installation

You should have Go 1.1 installed.

Install the following modules:

go get github.com/mehrvarz/rtcchat2
go get github.com/steveyen/gkvlite
go get code.google.com/p/go.net/websocket

Initialize the callee service key/value flat file DB.

cd $GOPATH/src/mehrvarz/rtcchat2
go run rtcchat/gkvCreate.go

Run server without SSL keys (test mode)

rtc chat server should be run with SSL keys installed (see next section). For simple test purposes, you can run rtc chat server without SSL keys (and then use http instead of https):

go run rtcchat/main.go -secure=false

Run server with SSL keys (standard mode)

Create SSL keys for use with HTTPS:

mkdir keys && cd keys
openssl req -new -x509 -nodes -out cert.pem -keyout key.pem -days 100
(answer questions)
cd ..

Alternative: create symbolic links to your existing keys from /etc/nginx

mkdir keys && cd keys
ln -s /etc/nginx/cert.pem cert.pem
ln -s /etc/nginx/key.pem key.pem
cd ..

Note: the "keys" subfolder is expected to contain two files: "cert.pem" and "key.pem".

This is how your installation folder should look:

rtcchat2/

	html/
		index.html
		spinner.gif
		bootstrap.min.css
		...

	rtcchat/
		main.go
		gkvCreate.go
		...

	keys/
		key.pem
		cert.pem

	rtcSignaling.go
	calleeService.go
	callerService.go
	calleePersistKey.go
	udpProxy.go
	stun.go
	LICENSE
	...

To run rtc chat server:

go run rtcchat/main.go

Or simply:

./run

Test your server

  1. Open the following URL in two browser tabs:

    https://127.0.0.1:8077

    or: http://127.0.0.1:8077 for insecure test mode

  2. Enter the same 'secret word' in both browser tabs. You should see the two instances connect.

More Info

You find more info here: http://mehrvarz.github.io/rtcchat2

License

This project uses code from:

bootstrap.js: Copyright 2012 Twitter, Inc; Apache License, Version 2.0.
jquery: Copyright jQuery Foundation and contributors; MIT License.
adapter.js + serverless-webrtc.js: Copyright 2013 Chris Ball chris@printf.net.
gkvlite: Copyright Steve Yen; MIT license.

For the rest:

Copyright (C) 2013 Timur Mehrvarz

Permission is hereby granted, free of charge, to any person obtaining a copy of serverless-webrtc and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CalleeMap = make(map[string]*websocket.Conn, maxCallees)
View Source
var MakeKeyMap = make(map[string]string, maxMakeKeys)
View Source
var TAG = "CallerService"
View Source
var TAG2 = "RtcSignaling"
View Source
var TAG3 = "CalleeService"
View Source
var TAG5 = "UdpProxy"
View Source
var TAG6 = "CalleePersistKey"

Functions

func BGCleaner

func BGCleaner()

func CalleeService

func CalleeService(secure bool, sigport int, callerPort int, autoAnswer string)

func CallerService

func CallerService(secure bool, callerport int, sigport int)

func CreateNewKeys

func CreateNewKeys() (string, string)

func GkvCreate

func GkvCreate()

func GkvInit

func GkvInit()

func GkvSet

func GkvSet(key string, user UserInfo)

func HostAddrIP4

func HostAddrIP4(hostaddr string) net.IP

func RtcSignaling

func RtcSignaling(secure bool, sigport int, stunport int, stunhost string, setRingtone string)

func StoreNewKeys

func StoreNewKeys(calleeKey string, callerKey string)

func StunUDP

func StunUDP(hostaddr string, port int)

func UdpProxy

func UdpProxy(hostAddr string, addr string, port string, sessionNumber int, proxyNumber int) (*net.UDPAddr, error)

func UdpProxyWorker

func UdpProxyWorker(c *net.UDPConn, target string, sessionNumber int, proxyNumber int, proxyname string)

func WsHandler

func WsHandler(cws *websocket.Conn)

handle all client websockets sessions

func WsHandlerCallee

func WsHandlerCallee(cws *websocket.Conn)

handle all callee websockets sessions

func WsHandlerCaller

func WsHandlerCaller(cws *websocket.Conn)

handle all caller websockets sessions

func WsSessionHandler

func WsSessionHandler(cws *websocket.Conn, done chan bool)

handle one complete websockets session

func WsSessionHandlerCallee

func WsSessionHandlerCallee(cws *websocket.Conn, doneWsSessionHandlerCallee chan bool)

handle one complete websockets session

func WsSessionHandlerCaller

func WsSessionHandlerCaller(cws *websocket.Conn, doneWsSessionHandler chan bool)

handle one complete websockets session

Types

type UserInfo

type UserInfo struct {
	Value        string
	Created      time.Time
	LastAccessed time.Time
	Counter      int
	AutoAnswer   bool
	Flag2        bool
	Flag3        bool
	Int1         int
	Int2         int
	Int3         int
}

func GkvGet

func GkvGet(key string) UserInfo

Directories

Path Synopsis
see: https://github.com/steveyen/gkvlite
see: https://github.com/steveyen/gkvlite

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL