mirror of https://github.com/zlatinb/muwire
implement rejection suggestions
parent
520d04cba4
commit
977b273656
|
@ -12,6 +12,7 @@ import com.muwire.core.hostcache.HostCache
|
||||||
import com.muwire.core.trust.TrustLevel
|
import com.muwire.core.trust.TrustLevel
|
||||||
import com.muwire.core.trust.TrustService
|
import com.muwire.core.trust.TrustService
|
||||||
|
|
||||||
|
import groovy.json.JsonOutput
|
||||||
import groovy.util.logging.Log
|
import groovy.util.logging.Log
|
||||||
|
|
||||||
@Log
|
@Log
|
||||||
|
@ -143,7 +144,18 @@ class ConnectionAcceptor {
|
||||||
} else {
|
} else {
|
||||||
log.info("rejecting connection, leaf:$leaf")
|
log.info("rejecting connection, leaf:$leaf")
|
||||||
e.outputStream.write("REJECT".bytes)
|
e.outputStream.write("REJECT".bytes)
|
||||||
// TODO: suggest peers
|
def hosts = hostCache.getHosts(10)
|
||||||
|
if (!hosts.isEmpty()) {
|
||||||
|
def json = [:]
|
||||||
|
json.tryHosts = hosts.collect { d -> d.toBase64() }
|
||||||
|
json = JsonOutput.toJson(json)
|
||||||
|
def os = new DataOutputStream(e.outputStream)
|
||||||
|
os.writeShort(json.bytes.length)
|
||||||
|
os.write(json.bytes)
|
||||||
|
}
|
||||||
|
e.outputStream.flush()
|
||||||
|
e.close()
|
||||||
|
eventBus.publish(new ConnectionEvent(endpoint: e, incoming: true, status: ConnectionAttemptStatus.REJECTED))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue