Rename the package as katzenpost

parent 4d3768b1
.*.swp
*.so
*.pyc
data
all: python
all: katzenpost.so
python:
GODEBUG=cgocheck=0 gopy bind -lang="py2" .
katzenpost.so: python/*.go
GODEBUG=cgocheck=0 gopy bind -lang="py2" ./python
#!/usr/bin/env python
# client.py - python example mixnet client
# Copyright (C) 2017 Yawning Angel.
# Copyright (C) 2017 Ruben Pollan.
# Copyright (C) 2018 Ruben Pollan.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
......@@ -16,24 +16,34 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import minclient
import katzenpost
name = "alice"
provider = "example.com"
keyStr = "4d488962dd5a7c2d2d2360a6bbe258bf75022eb39a05b8c877f3f92e99fd298c"
pkiAddr = "192.0.2.1:29483"
pkiKey = "900895721381C0756D28954524BB1D090F54C8DD9295F84B1D8A93F1E3C17AD8"
linkKey = "4d488962dd5a7c2d2d2360a6bbe258bf75022eb39a05b8c877f3f92e99fd298c"
key = katzenpost.StringToKey(linkKey)
client = minclient.NewClient(pkiAddr, pkiKey, minclient.LogConfig())
key = minclient.StringToKey(keyStr)
session = client.NewSession(name, provider, key)
session.WaitToConnect()
cfg = katzenpost.Config(
PkiAddress="192.0.2.1:29483",
PkiKey="900895721381C0756D28954524BB1D090F54C8DD9295F84B1D8A93F1E3C17AD8",
User="alice",
LinkKey=key,
Provider="example.com",
Log=katzenpost.LogConfig()
)
session.SendMessage("bob", "panoramix.org", "hello bob!!!")
print("Message sent")
c = katzenpost.New(cfg)
while 1:
mail = """From: alice@example.com
To: bob@panoramix.com
Subject: hello
Hello there.
"""
c.Send("bob@panoramix.com", mail)
while True:
try:
print(session.GetMessage(1))
m = c.GetMessage(1)
except RuntimeError:
pass
continue
print("=================>" + m.Sender)
print(m.Payload)
package client
// client.go - mixnet client
// Copyright (C) 2017 Yawning Angel.
// Copyright (C) 2018 Ruben Pollan.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package katzenpost
import (
"errors"
......@@ -23,6 +40,7 @@ type Client struct {
eventSink chan event.Event
}
// New creates a katzenpost client
func New(cfg Config) (Client, error) {
eventSink := make(chan event.Event)
dataDir, err := cfg.getDataDir()
......@@ -56,11 +74,13 @@ func New(cfg Config) (Client, error) {
return Client{cfg.getAddress(), proxy, eventSink}, err
}
// Shutdown the client
func (c Client) Shutdown() {
c.proxy.Shutdown()
c.proxy.Wait()
}
// Shutdown a message into katzenpost
func (c Client) Send(recipient, msg string) error {
var identityKey ecdh.PrivateKey
identityKey.FromBytes(identityKeyBytes)
......@@ -68,11 +88,13 @@ func (c Client) Send(recipient, msg string) error {
return c.proxy.SendMessage(c.address, recipient, []byte(msg))
}
// Message received from katzenpost
type Message struct {
Sender string
Payload string
}
// GetMessage from katzenpost
func (c Client) GetMessage(timeout int64) (Message, error) {
if timeout == 0 {
ev := <-c.eventSink
......
package client
// config.go - mixnet client configuration
// Copyright (C) 2017 Yawning Angel.
// Copyright (C) 2018 Ruben Pollan.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package katzenpost
import (
"fmt"
......@@ -10,6 +27,7 @@ import (
"github.com/katzenpost/mailproxy/config"
)
// Config has the client configuration
type Config struct {
PkiAddress string
PkiKey string
......
......@@ -15,7 +15,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package client
package katzenpost
import (
"encoding/hex"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment