Adding groups / inivite to cli

This commit is contained in:
Sarah Jamie Lewis 2018-05-01 14:36:03 -07:00
parent 8d8eb89507
commit 383828512a
7 changed files with 37 additions and 5 deletions

4
.gitignore vendored
View File

@ -3,5 +3,5 @@
*private_key*
*.messages
*.test
*test_*
*_test*
*/*test_*
*/*_test*

View File

@ -73,6 +73,29 @@ func main() {
for _, c := range app.Peer.Profile.Contacts {
fmt.Printf("Name: %v, Onion: %v, Trusted: %v\n", c.Name, c.Onion, c.Trusted)
}
case "groups":
for gid, g := range app.Peer.Profile.Groups {
fmt.Printf("Group Id: %v, Owner: %v\n", gid, g.Owner)
}
case "invitetogroup":
if len(commands) == 3 {
fmt.Printf("Inviting %v to %v\n", commands[1], commands[2])
err := app.Peer.InviteOnionToGroup(commands[1], commands[2])
if err == nil {
fmt.Printf("Error: %v", err)
}
} else {
fmt.Printf("Error inviting peer to group, usage: invitetogroup [onion] [groupid]\n")
}
case "newgroup":
if len(commands) == 2 {
fmt.Printf("Setting up a new group on server:%v\n", commands[1])
id, _ := app.Peer.Profile.StartGroup(commands[1])
fmt.Printf("New Group [%v] created for server %v", id, commands[1])
app.Peer.Save(profilefile)
} else {
fmt.Printf("Error inviting peer, usage: newgroup [server]\n")
}
case "save":
app.Peer.Save(profilefile)
}

View File

@ -1 +1 @@
{"Name":"Sarah","Ed25519PublicKey":"h+bF9c0SF514SkwRTOBgze4RSH3SkzHryQtp1QX7K2c=","Trusted":false,"Blocked":false,"Contacts":{},"Ed25519PrivateKey":"JjIjdHerRDvam7YGAWRB9TKbcmaF/GmTO7W7T1Te7r+H5sX1zRIXnXhKTBFM4GDN7hFIfdKTMevJC2nVBfsrZw==","OnionPrivateKey":{"N":150334126587032943045375148713167145976886112307031077390166965660647397991493965621432524457750584545841938427575399071242079289459226603323287102292760674425182877649538534621234856024017965368741906106193407381804550153239904811184111592035493922499127339448275867606246302761523482667273192866558668080259,"E":65537,"D":17366978537168720139715508047475295820544192689267624195812351755752650414172159447638214179312902262791542423900595791207619852915083153238027475341539754340816153242259456537434649233588080599834443260629563433852148656237140776914076713110935213796722635544420400426643090954804506516101309871975668441593,"Primes":[11730504892727445290895356094153341596474633870692621163241582324218351073716900128761763998613547851126172912259562433380314953294172830665823918633624781,12815656952688840304471638290754355930607045572334470447975334064993954543008612625605710491332383344451860137114481415847832249366470174722911129087069839],"Precomputed":{"Dp":5911521508340469286393959530060918456852888182970920230684647442238117108070983727552600509364323128601310904881159779777097852548127715311963723708938853,"Dq":4480992097149164221385897911601630623157307311748239777764541863364762933198687128122356163829311142379333430611385044236890245116997483158757778400448683,"Qinv":6197546791251079424328183450454885431371453146097562073580934109929339902017994626469294302315196356224665374413915068750396374123676212919551474229908475,"CRTValues":[]}},"Onion":"lzxwmhuxme3i5kf5","Groups":{}}
{"Name":"Sarah","Ed25519PublicKey":"pjGwKR7x//668k6L5wauq2kRHVZ/lYky5MjXpwEfMd0=","Trusted":false,"Blocked":false,"Onion":"3lyxnb3fvvoxckmd","Contacts":{},"Ed25519PrivateKey":"dp1Q4qWVlARsj/BQOUbYYnf3dv5lcDMGZBWLnhJSObSmMbApHvH//rryTovnBq6raREdVn+ViTLkyNenAR8x3Q==","OnionPrivateKey":{"N":104322982725073731343467255206252886552056394891229470830430445244399535822960412330061824331803282799656157319003354545152087182167549118638892463467050712913051438261600330540653694100091527418204046955338894680514656487165220800975241292027426651186322677654572046274767746004077197562589739087897592388461,"E":65537,"D":37711762572893507015244560219285855857069564541680537611482485897814507883817616438218024631044319587510170179356828547678381638352860310506645121870056578049998372381097845595468504449855843030205150374468862641585067268172868653777280578453378382612290205222199733083704617982297305686009347195060622538389,"Primes":[10269478124505799344617374185000453210872409922153471500829708056024847939877279592930504708378550618626013433035769805183604484066733989558479869055996567,10158547636041056589030357328688081084488449355054217828575319683339602102460878475710722876178116196087450209800800570618256001956005080929114943060080283],"Precomputed":{"Dp":5003348284411403834072855909288866915225842635676951111913767463095249930883036107882127887125244079721815293907748750774562326262276519929234817262889213,"Dq":894842539372644760798819794292022706269005571306712231630457917388948577711928398313593896030887358286355037020004298246474386976700449092936517788208851,"Qinv":2292076693255724557620015290537832426320764862565620479893520205435832971255410669098215083615971634730254402569251452252795647765272350723031334156178634,"CRTValues":[]}},"Groups":{}}

View File

@ -9,6 +9,7 @@ import (
"github.com/s-rah/go-ricochet/identity"
//"github.com/s-rah/go-ricochet/utils"
"git.mascherari.press/cwtch/model"
"log"
"time"
)
@ -51,6 +52,7 @@ func (ppc *PeerPeerConnection) SendGroupInvite(invite []byte) {
if channel != nil {
peerchannel, ok := channel.Handler.(*peer.CwtchPeerChannel)
if ok {
log.Printf("Sending group invite packet\n")
peerchannel.SendMessage(invite)
}
}

View File

@ -3,6 +3,7 @@ package peer
import (
"encoding/json"
"errors"
"fmt"
"git.mascherari.press/cwtch/model"
"git.mascherari.press/cwtch/peer/connections"
"git.mascherari.press/cwtch/peer/peer"
@ -80,9 +81,11 @@ func (cp *CwtchPeer) PeerWithOnion(onion string) {
// InviteOnionToGroup kicks off the invite process
func (cp *CwtchPeer) InviteOnionToGroup(onion string, groupid string) error {
group := cp.Profile.GetGroupByGroupId(groupid)
if group == nil {
if group != nil {
fmt.Printf("Constructing invite for group: %v\n", group)
invite := group.Invite()
ppc := cp.connectionsManager.GetPeerPeerConnectionForOnion(onion)
fmt.Printf("Got connection for group: %v - Sending Invite\n", ppc)
ppc.SendGroupInvite(invite)
}
return errors.New("group id could not be found")
@ -158,6 +161,7 @@ func (cph *CwtchPeerHandler) ClientIdentity(ci *protocol.CwtchIdentity) {
}
func (cph *CwtchPeerHandler) HandleGroupInvite(gci *protocol.GroupChatInvite) {
log.Printf("Received GroupID from %v %v\n", cph.Onion, gci.String())
cph.Peer.Profile.ProcessInvite(gci, cph.Onion)
}

View File

@ -6,6 +6,7 @@ import (
"github.com/s-rah/go-ricochet/channels"
"github.com/s-rah/go-ricochet/utils"
"github.com/s-rah/go-ricochet/wire/control"
"log"
)
// CwtchPeerChannel implements the ChannelHandler interface for a channel of
@ -107,5 +108,7 @@ func (cpc *CwtchPeerChannel) Packet(data []byte) {
} else if cpp.GetGroupChatInvite() != nil {
cpc.Handler.HandleGroupInvite(cpp.GetGroupChatInvite())
}
} else {
log.Printf("Error Receivng Packet %v\n", err)
}
}

View File

@ -1 +1 @@
{"Profile":{"Name":"alice","Ed25519PublicKey":"HePVPZDgQV5CPsKsfk8k9APAbFAaHo3h5IgcOLk8JkU=","Trusted":false,"Blocked":false,"Contacts":{},"Ed25519PrivateKey":"vW4vk9yJONpqLoooQrJLT3BsiJjNseagLkQelqIQppgd49U9kOBBXkI+wqx+TyT0A8BsUBoejeHkiBw4uTwmRQ==","OnionPrivateKey":{"N":124180052987038276908488971306097118499288790640484988517147166769877815582841930618153187145182425589345556238768813257991033435204827844882770722270092969225417271833713672261037744190852387384632814869090061694598739251480895491455885307591459276013910000175922066726291096488800388268492421362423280138243,"E":65537,"D":8323892957749960334757343957576401751184455456973168661303195196912785813440111711026549142145450594534309299432555604351047650653139581039260444984245820156701213023813296520282033216231123406154310401988822683123845588539154050789818510723459725427699399566036015352152852003341066008723635142189324534393,"Primes":[10318605891039665378109893427013360413384828451813995161940801274879978602208412774582196558435137474501959569416200754358158605387475412222231908504565973,12034576598653904425712782466302887117485091173704960260057943271715893247294740735187656822073438435145528143604740414620929110675044452637939150841583991],"Precomputed":{"Dp":1751913083442915553995892155002176805769763434141543313958760635756740801482719821517251340551257681596400569585029308539347708960532812179330369805305485,"Dq":11627835564337130720737672022387833102726565807121862361526909743375403088411089504151133028477566391355801045353607466539915973361080989821621113410604413,"Qinv":5168969236254874132993321993214963606790484960035248152574500117234718152121266178902971986905125868496286012732445791508496771810043600157469938696477522,"CRTValues":[]}},"Onion":"lxjwzgx5jwl7otgt","Groups":{}}}
{"Profile":{"Name":"alice","Ed25519PublicKey":"zw62CDBry+8i5C0SEoN0Nj4BbZV3/WL8NOra9H9d0Rc=","Trusted":false,"Blocked":false,"Onion":"kzqdsapmr2yv2vd2","Contacts":{},"Ed25519PrivateKey":"QPdpHBOh0noZ4qnJbFoNe0/GZ8ad7FTjYcTXHnedEjHPDrYIMGvL7yLkLRISg3Q2PgFtlXf9Yvw06tr0f13RFw==","OnionPrivateKey":{"N":123164664477389835253620680122644142133034167846356214569188233954912552260600272847127308026339070666831186661931126823098497770011055113279368507758948331028994964297854804880407367476974939435091231218755171920902867841609756476585968731169532272132417713193102472875109807766299347704731437376645583569401,"E":65537,"D":95474837869368994619675777229209306998863769002219124597684816967688822993046304552430056756673387660207589239453851045880540491781308770922253967982633488453491426433469372420149066383652671754998024517772855722930373092680126685828740579513880385080148346315945547711747598115997648389837723796594848638621,"Primes":[11542678133022281192358295468401730074073008626984537974633501998980589167293816424678327803995971301193759072785039888972745795144308685183240956357855487,10670371560048081490791125355690298205739475562665387017071396147459233736780172095647046771702789510862828944882599608718851613825219072553675924318223623],"Precomputed":{"Dp":4601959762237197083710421628909910510176749659192196663551868009389563366529138186984757117210289365227150019268509502402747682703291905872299662002752735,"Dq":6190205940354731804627593359832539447674059857676396758915642789972077859413493798564180817860751288630922326082006151082453245611407741252891628279885593,"Qinv":2696633387876221595461120113944631143313663626921228123107813313410377087409781969143836679473288905741449629397529356977312616100311173108943456308317853,"CRTValues":[]}},"Groups":{}}}