Giter Site home page Giter Site logo

coalago's Introduction

Coala

Coala is a Go-Lang library for secure peer-to-peer communication based on Constrained Application Protocol (CoAP, see RFC#7252).

COAP diff:

  • curve cripto
  • arq fast data transmission (30MBit./s) + OptionSelectiveRepeatWindowSize option

Installation

go get -u github.com/gusleein/coalago

Usage

Basic

coala := Coala.NewCoala()

Simple server & Simple client

package main

import (
	"fmt"
	"net"
	"github.com/gusleein/coalago"
	"github.com/gusleein/coalago/resource" 
)

func main() {
	server()
	client()
}

func server() {
	coalaServer := coalago.NewListen(5683)

	coalaServer.GET("/parrot", func(message   *CoAPMessage) *resource.CoAPResourceHandlerResult {
		word := message.GetURIQuery("word")
		handlerResult := resource.NewResponse( NewStringPayload(word), CoapCodeContent)
		return handlerResult
	})
}

func client() {
	coalaClient := coalago.NewCoala()
	requestMessage := NewCoAPMessage( CON, GET)
	requestMessage.SetURIPath("/parrot")
	requestMessage.SetURIQuery("word", "hello world!")

	address, err := net.ResolveUDPAddr("udp", "127.0.0.1:5683")
	if err != nil {
		fmt.Println(err)
		return
	}

	responseMessage, err := coalaClient.Send(requestMessage, address)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println("RESPONSE: ", responseMessage.Payload.String())
}

Encrypted Messaging

Coala is designed to be strongly secured, simple and lightweight and the same time.

Switching between standard and secured connections is easy as is, just specify "coaps" scheme in your request:

request := coalago.NewCoAPMessage(coalago.CON, coalago.GET)
requestMessage.SetSchemeCOAPS()
request.SetStringPayload("Put your innermost secrets here... And nobody will be able to read it...")

coalago's People

Contributors

alexeyspiridonov avatar medn51 avatar mednnn avatar gusleein avatar dzen-it avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.