Popularity
0.4
Declining
Activity
0.0
Stable
2
2
0

Programming language: Go
License: MIT License
Tags: RPC     Crawler     Tor     Onion    

jsonrpconion alternatives and similar packages

Based on the "Crawler" category.
Alternatively, view jsonrpconion alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of jsonrpconion or a related project?

Add another 'Crawler' Package

README

jsonrpconion

Build Status Go Report Card GoDoc [License MIT](LICENSE)

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


*Note that all licence references and agreements mentioned in the jsonrpconion README section above are relevant to that project's source code only.