forked from cwtch.im/cwtch
parent
9a4693c223
commit
c29186979f
@ -1 +1 @@
|
||||
{"Name":"Sarah","Ed25519PublicKey":"T7ug35aRhuImJfE90ymczSgAi90cHdbQMqEhBM/4+T0=","Contacts":{},"Ed25519PrivateKey":"TSquPGWkVc13XEbOkkFaSmQgArJ3vhUAnOHUpipXiZNPu6DflpGG4iYl8T3TKZzNKACL3Rwd1tAyoSEEz/j5PQ==","OnionPrivateKey":{"N":147543015664120090366421447952970860504590941099804565923233227773815393474636918222730428033531903648100909217280034128017566946683746667285202590815509702891937867545391137542704927905354957814668191780596816701004171603996891826892371194711906073796279656017597798465364500891427388525790476841047404602167,"E":65537,"D":5684515839173340680458583030673534381709448498970147076554677512380546386368894189730905149528786131673021282231900852545041069020194093945330676439403114856356392314290322709016451155034411809521466849420244883177134443565565861016638701771436637981361005194284315380514984476353929411384168768558877308473,"Primes":[12931099477754593259784498055463781428153030935578361605358730348734406074416483185277800291372847230179833495402846932178915478884892963290117615988576301,11409935861829750400775707403393062540845554732277302700883351106026835771931816136175131558089707680685127543513601477653608896039540199753620444032990067],"Precomputed":{"Dp":3748099023138475266839591758267695988665867764045448480330110345370687974573378619520836997954111509292401499590650782362187442771219719100036227372613873,"Dq":1182655512297015342058217196259350807024487744272086260388797230011143253410025283626618073364715874618827096191279656342233627276143195094776136782521347,"Qinv":12011761893821155933799466829578837010916497100434672750257270979155184673238141008807799214221585212198300042270714718819586501480079276451027729262322408,"CRTValues":[]}},"Groups":{}}
|
||||
{"Name":"Sarah","Ed25519PublicKey":"08Q49pmOe/8Edn/jR1Qq8d26SU1MzPbJ2PmJ64S6BY8=","Trusted":false,"Blocked":false,"Contacts":{},"Ed25519PrivateKey":"/hhjerGW66QyhAKPtwGbBBzhY5/auK6T2b/vjRGuXnjTxDj2mY57/wR2f+NHVCrx3bpJTUzM9snY+YnrhLoFjw==","OnionPrivateKey":{"N":146328154189193884086641737732621103864374553173215703384122944250992002089624680210913011506081609406766798073335357829207459154214042241028123233139603802979024475926282158611908322463042012748984945285776401165814190414695182764240512995788636041616865870623261762908273890987461235956226167821197856348839,"E":65537,"D":131000281712443101868127073809425903015557376501501621205628292187530749753611841209312116988644890475820095160882129401029342867327559796231167833968091809253818237330927694966481136799400760644381429766064366889564088512676631446803130802140311950212661905465119640487794003192289760147304713580532618877313,"Primes":[11046905119315044599912769443513046649297228971109751902148448569336221142449837623971448415395377389790939200512488865059980264758837294990542341171570219,13246076852180554978507253920836715985718751717246338099834768101497493531807293249274887847720805074264534287152405900588792629153510158525691602692356981],"Precomputed":{"Dp":9951771949347089936659442878755668922509550306762893515157001442446411893285295532588832483100280468945131000782113044435070797127756136171042614443284033,"Dq":6285403633811601060799526716666618760759292321939158372044213473615958219816946235957557750406970050497863607761501422044192947211740832046507430314584393,"Qinv":6371034795994819655941418536323418056681675622606010416374029760428023006446243689515420082688972242794843497150013283993628462297774942497647603736899599,"CRTValues":[]}},"Onion":"3qs4j52zt24qqnor","Groups":{}}
|
@ -0,0 +1,73 @@
|
||||
package connections
|
||||
|
||||
import (
|
||||
"git.mascherari.press/cwtch/model"
|
||||
"time"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type Manager struct {
|
||||
peerConnections map[string]*PeerPeerConnection
|
||||
serverConnections map[string]*PeerServerConnection
|
||||
lock sync.Mutex
|
||||
}
|
||||
|
||||
func NewConnectionsManager() *Manager {
|
||||
m := new(Manager)
|
||||
m.peerConnections = make(map[string]*PeerPeerConnection)
|
||||
m.serverConnections = make(map[string]*PeerServerConnection)
|
||||
return m;
|
||||
}
|
||||
|
||||
func (m *Manager) ManagePeerConnection(host string, profile *model.Profile) {
|
||||
m.lock.Lock()
|
||||
ppc := NewPeerPeerConnection(host, profile)
|
||||
go ppc.Run()
|
||||
m.peerConnections[host] = ppc
|
||||
m.lock.Unlock()
|
||||
|
||||
}
|
||||
|
||||
func (m *Manager) ManageServerConnection(host string) {
|
||||
m.lock.Lock()
|
||||
psc := NewPeerServerConnection(host)
|
||||
go psc.Run()
|
||||
m.serverConnections[host] = psc
|
||||
m.lock.Unlock()
|
||||
}
|
||||
|
||||
func (m *Manager) GetPeerPeerConnectionForOnion(host string) (ppc *PeerPeerConnection) {
|
||||
m.lock.Lock()
|
||||
ppc = m.peerConnections[host]
|
||||
m.lock.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
func (m *Manager) GetPeerServerConnectionForOnion(host string) (psc *PeerServerConnection) {
|
||||
m.lock.Lock()
|
||||
psc = m.serverConnections[host]
|
||||
m.lock.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
func (m *Manager) AttemptReconnections() {
|
||||
m.lock.Lock()
|
||||
for _, ppc := range m.peerConnections {
|
||||
if ppc.GetState() == FAILED {
|
||||
go ppc.Run()
|
||||
}
|
||||
}
|
||||
m.lock.Unlock()
|
||||
|
||||
m.lock.Lock()
|
||||
for _, psc := range m.serverConnections {
|
||||
if psc.GetState() == FAILED {
|
||||
go psc.Run()
|
||||
}
|
||||
}
|
||||
m.lock.Unlock()
|
||||
|
||||
// Launch Another Run In 30 Seconds
|
||||
time.Sleep(time.Second * 30)
|
||||
go m.AttemptReconnections()
|
||||
}
|
@ -1 +1 @@
|
||||
{"Profile":{"Name":"alice","Ed25519PublicKey":"jd/KsmjnaiNRQfwkUU2KOv78epqHQtc/NuQ7vHhL1pU=","Contacts":{},"Ed25519PrivateKey":"hJqPzncQMthT/C6MJe5wwqijF8LZlItwuVqRRPWF2uSN38qyaOdqI1FB/CRRTYo6/vx6modC1z825Du8eEvWlQ==","OnionPrivateKey":{"N":116625881909264071736606689586851027031866677768702967565587135989634906670425929131611970003568513685918847077357562012284752737018357715084617885889134319857398716428989490466264550714347160579478956149389453246821375180647178126226570098474391873393638846273276470804476875874646605047892383342437534890107,"E":65537,"D":74117948357734540608048409620402906386884464181553604820280211391554295479244395506837947276326786319461067500372956617050825510731565357481641438382630323642658160945533297126458940294613864770177502808097743782578588323228321725977812335445321391168916952291786105711946242663437273644485564881061465737473,"Primes":[10118822147491588191804307827889610500703007978301844285618895021194403722583146885313445367368523265387812462145972329196076399224393167672743566765418817,11525638084090164427262755292570520360826215923789098544956165178885657272566959447401401652883909093499220795453042380071024329286949114855482181086877371],"Precomputed":{"Dp":7235119182011013971770905973952227719653675845144337141219485492060511748176545509342631641895250014740877549722450880359615790586310997408254322575453953,"Dq":2255287590069308461101630740984853641564847231436767013145518749012461187777876435501710099586237548484581343071697140272377679765259860062357195023545713,"Qinv":6483591420973981267201623607283357903939001496206473754008877212497299522594502989717337115365261073580285165813624061295197296922762434701906760350701367,"CRTValues":[]}},"Groups":{}},"PendingContacts":null,"PendingInvites":{}}
|
||||
{"Profile":{"Name":"alice","Ed25519PublicKey":"woBpoPixOQlewrOj55rvUUJXO6SYjSbds+x5wBSD/nE=","Trusted":false,"Blocked":false,"Contacts":{},"Ed25519PrivateKey":"zF81FX4HdjfH8y9GEkkMuP3grW+6YHLUq5xt2BGdu93CgGmg+LE5CV7Cs6Pnmu9RQlc7pJiNJt2z7HnAFIP+cQ==","OnionPrivateKey":{"N":139926795769138065515184049224038533094758142244011440346432394711998122006646506685316823692319561121294993561288095105636848170048849868725177766607476321666954798718648650798310074246526178993249155964685028684884855868827006247404286011381915601081225045627232142906774434198218068995980294397037791794267,"E":65537,"D":80563006923674971788217949087853364805598501324340199865601622742387126930997644639776915458173154092952438958879467974136673817850271634292188117664829075982704832540445727518368206591976958327683396293490831042373962322741974344132577591789404120121585476701598634477623181079921183580001754668835068766913,"Primes":[11996718101524297693400014654326964581090960285071398726861380106816214227409962837267266227138498003607972122710998689259606190329862913588172576335353147,11663756252750410861345204036901556299677356139785595193403181361865123292907581200748114782681955962873888839331259846486482553416702234941039306713860961],"Precomputed":{"Dp":3630482172017812779852640350325261890791110599109221522954083214954696992114710666516955171625766069633289761657189633399236607913272978091676865075591787,"Dq":476609232111106707458114598025884123022658341735902222072016108260597832955528975320863808047702489716896933209166026349860388453086479167067507871579713,"Qinv":8004940118786479816457227792582435507151418905449158436675099080630617341053710180416725805457646331045119350055846124889161926521155923764007407649644659,"CRTValues":[]}},"Groups":{}}}
|
Loading…
Reference in new issue