Compare commits
3 Commits
python-bin
...
python-add
| Author | SHA1 | Date | |
|---|---|---|---|
| 5f8407a37f | |||
| a6939ec35e | |||
|
|
c445ac88c4 |
@@ -142,6 +142,15 @@ func MapPort(Port string, DomainName string, ServerAddress string) *C.char {
|
||||
return C.CString(Address.EntireAddress)
|
||||
}
|
||||
|
||||
//export CustomInformation
|
||||
func CustomInformation(CustomInformation string) *C.char {
|
||||
err := abstractions.AddCustomInformation(CustomInformation)
|
||||
if err != nil {
|
||||
return C.CString(err.Error())
|
||||
}
|
||||
return C.CString("Success")
|
||||
}
|
||||
|
||||
// --------------------------------- Controlling Server ----------------------------------------
|
||||
|
||||
//export Server
|
||||
|
||||
@@ -98,5 +98,17 @@ def ListNodes():
|
||||
dat: IPAddress = dacite.from_dict(IPAddress,ipTableObject)
|
||||
return dat
|
||||
|
||||
# python function to pass-through custom
|
||||
# information to interpret which can be
|
||||
# interpreted as a DSL.
|
||||
def AddCustomInformation(message="") -> bool:
|
||||
message = go_string(c_char_p(message.encode('utf-8')), len(message))
|
||||
|
||||
p2prc.CustomInformation.restype = c_char_p
|
||||
status = p2prc.CustomInformation(message)
|
||||
if str(status).strip("b'") == "Success":
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,3 +5,7 @@ if __name__ == "__main__":
|
||||
P2PRCNodes = ListNodes()
|
||||
# Print nodes in the network
|
||||
print(P2PRCNodes)
|
||||
|
||||
# Add custom information to the network
|
||||
if AddCustomInformation("Test"):
|
||||
print("It worked")
|
||||
|
||||
@@ -86,3 +86,10 @@ func ViewIPTable() (table *p2p.IpAddresses, err error) {
|
||||
func UpdateIPTable() (err error) {
|
||||
return clientIPTable.UpdateIpTableListClient()
|
||||
}
|
||||
|
||||
// AddCustomInformation allows to pass custom information
|
||||
// through the network to which can be listened on
|
||||
// all peers in the network to execute a task.
|
||||
func AddCustomInformation(information string) error {
|
||||
return clientIPTable.AddCustomInformationToIPTable(information)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user