• Stars
    star
    2
  • Language
    Go
  • License
    MIT License
  • Created over 5 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Library for building JSON RPC services on Tor network

jsonrpconion

Build Status Go Report Card GoDoc License MIT

Library for building JSON RPC services on Tor network

Install

go get github.com/MarinX/jsonrpconion

Usage

Take a look at _examples directory which contains a simple echo server/client and math which contains JSON RPC server

Server

Create a simple JSON RPC server on Tor.

package main

import (
	"fmt"
	"time"

	"github.com/MarinX/jsonrpconion"
)

type Service struct{}

func (Service) Say(in *string, out *string) error {
	*out = fmt.Sprintf("Hello, %s", *in)
	return nil
}

func main() {

	// creates new server
	srv := jsonrpconion.NewServer()

	// register our service Service
	if err := srv.Register(new(Service)); err != nil {
		fmt.Println(err)
		return
	}

	go func() {
		for {
			addr, err := srv.Addr()
			if err != nil {
				time.Sleep(time.Second)
				continue
			}

			fmt.Println("Onion V3 address:", addr)
			break
		}
	}()

	// Run with blocking
	// If you want to run a server without blocking
	// call srv.RunNotify() which will return onion address
	if err := srv.Run(); err != nil {
		fmt.Println(err)
		return
	}
	defer srv.Stop()
}

Client

Create a simple client to call onion JSON RPC endpoint

package main

import (
	"fmt"

	"github.com/MarinX/jsonrpconion"
)

type Service struct{}

func (Service) Say(in *string, out *string) error {
	*out = fmt.Sprintf("Hello, %s", *in)
	return nil
}

func main() {

	addr := "onion_v3_address"

	// creates new server
	cli, err := jsonrpconion.NewClient(addr)
	if err != nil {
		fmt.Println(err)
		return
	}
	defer cli.Close()

	reply := new(string)

	// calls our simple RPC service
	err = cli.Call("Service.Say", "Marin", reply)
	if err != nil {
		fmt.Println(err)
		return
	}

	// Should return Hello, Marin
	fmt.Println("Reply from JSON RPC endpoint:", *reply)

}

Test

go test -v

License

MIT

More Repositories

1

keylogger

Basic keylogger in Go (no C deps)
Go
235
star
2

godroid

Golang 1.4 beta on Android
Java
137
star
3

agewasm

A simple and secure online client-side Age key generator, encryption and decryption tool built using wasm
HTML
73
star
4

goble

Bluetooth Low Energy for Go
Go
45
star
5

btc-vanity

Generate Bitcoin Vanity Address
Go
27
star
6

yap

YAP! - Yet Another PGP Tool
Dart
17
star
7

mycommander-server

MyCommander Golang server application
Go
9
star
8

monerorpc

Full Monero RPC client(Wallet AND Daemon) written in go
Go
6
star
9

agemobile

Gomobile support for Age
Objective-C
6
star
10

mcastrpc

Golang Multicast JSON RPC Server
Go
6
star
11

vibrator

Port Android vibrator hardware to Go
Go
4
star
12

gogi

A car diagnostic tool written in go
Go
3
star
13

beanrpc

Beanstalkd RPC for go
Go
3
star
14

droneservo

A drone hardware fun plugin :)
Go
2
star
15

telegram-bots

Telegram bots in go
Go
2
star
16

monion

fast, secure messaging system for developing rich apps on Tor network.
2
star
17

go-mercedes-bot

Mercedes Benz Dealer Slack Bot in go
Go
2
star
18

chrome-image-recognition

Get image tags using image recognition and machine learning.
JavaScript
1
star
19

emacs-setup

My Emacs setup for C/C++ and GoLang
1
star
20

IoTOS

IoT OS for embedded, running OpenWRT or similliar linux distro
1
star
21

codeswholesale

Go wrapper for CodesWholesale API
Go
1
star
22

tor-phishy

A Tor browser plugin which block access to the phising sites.
JavaScript
1
star
23

mycommander

MyCommander Android app
Java
1
star
24

go-mercedes-dealer

Mercedes-Benz Dealer API library for go
Go
1
star
25

electrumrpc

Golang JSON RPC client to talk with Electrum server
Go
1
star
26

oc-steamauth

Steam API authentication for OctoberCMS
PHP
1
star
27

mqtt

Basic MQTT wrapper for Go
Go
1
star