projects
/
ldk-java
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #56 from TheBlueMatt/main
[ldk-java]
/
src
/
main
/
java
/
org
/
ldk
/
structs
/
NetAddress.java
diff --git
a/src/main/java/org/ldk/structs/NetAddress.java
b/src/main/java/org/ldk/structs/NetAddress.java
index 420d9bb5c23806ec4499f6cbc9491525d13655f2..242e169a35d64570e086c56e86eabf13dc665c22 100644
(file)
--- a/
src/main/java/org/ldk/structs/NetAddress.java
+++ b/
src/main/java/org/ldk/structs/NetAddress.java
@@
-35,6
+35,9
@@
public class NetAddress extends CommonBase {
assert false; return null; // Unreachable without extending the (internal) bindings interface
}
assert false; return null; // Unreachable without extending the (internal) bindings interface
}
+ /**
+ * An IPv4 address/port on which the peer is listening.
+ */
public final static class IPv4 extends NetAddress {
/**
* The 4-byte IPv4 address
public final static class IPv4 extends NetAddress {
/**
* The 4-byte IPv4 address
@@
-50,6
+53,9
@@
public class NetAddress extends CommonBase {
this.port = obj.port;
}
}
this.port = obj.port;
}
}
+ /**
+ * An IPv6 address/port on which the peer is listening.
+ */
public final static class IPv6 extends NetAddress {
/**
* The 16-byte IPv6 address
public final static class IPv6 extends NetAddress {
/**
* The 16-byte IPv6 address
@@
-65,6
+71,9
@@
public class NetAddress extends CommonBase {
this.port = obj.port;
}
}
this.port = obj.port;
}
}
+ /**
+ * An old-style Tor onion address/port on which the peer is listening.
+ */
public final static class OnionV2 extends NetAddress {
/**
* The bytes (usually encoded in base32 with \".onion\" appended)
public final static class OnionV2 extends NetAddress {
/**
* The bytes (usually encoded in base32 with \".onion\" appended)
@@
-80,6
+89,11
@@
public class NetAddress extends CommonBase {
this.port = obj.port;
}
}
this.port = obj.port;
}
}
+ /**
+ * A new-style Tor onion address/port on which the peer is listening.
+ * To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
+ * wrap as base32 and append \".onion\".
+ */
public final static class OnionV3 extends NetAddress {
/**
* The ed25519 long-term public key of the peer
public final static class OnionV3 extends NetAddress {
/**
* The ed25519 long-term public key of the peer
@@
-105,12
+119,17
@@
public class NetAddress extends CommonBase {
this.port = obj.port;
}
}
this.port = obj.port;
}
}
+ long clone_ptr() {
+ long ret = bindings.NetAddress_clone_ptr(this.ptr);
+ return ret;
+ }
+
/**
* Creates a copy of the NetAddress
*/
public NetAddress clone() {
long ret = bindings.NetAddress_clone(this.ptr);
/**
* Creates a copy of the NetAddress
*/
public NetAddress clone() {
long ret = bindings.NetAddress_clone(this.ptr);
- if (ret
< 1024
) { return null; }
+ if (ret
>= 0 && ret <= 4096
) { return null; }
NetAddress ret_hu_conv = NetAddress.constr_from_ptr(ret);
ret_hu_conv.ptrs_to.add(this);
return ret_hu_conv;
NetAddress ret_hu_conv = NetAddress.constr_from_ptr(ret);
ret_hu_conv.ptrs_to.add(this);
return ret_hu_conv;
@@
-120,8
+139,8
@@
public class NetAddress extends CommonBase {
* Utility method to constructs a new IPv4-variant NetAddress
*/
public static NetAddress ipv4(byte[] addr, short port) {
* Utility method to constructs a new IPv4-variant NetAddress
*/
public static NetAddress ipv4(byte[] addr, short port) {
- long ret = bindings.NetAddress_ipv4(
addr
, port);
- if (ret
< 1024
) { return null; }
+ long ret = bindings.NetAddress_ipv4(
InternalUtils.check_arr_len(addr, 4)
, port);
+ if (ret
>= 0 && ret <= 4096
) { return null; }
NetAddress ret_hu_conv = NetAddress.constr_from_ptr(ret);
ret_hu_conv.ptrs_to.add(ret_hu_conv);
return ret_hu_conv;
NetAddress ret_hu_conv = NetAddress.constr_from_ptr(ret);
ret_hu_conv.ptrs_to.add(ret_hu_conv);
return ret_hu_conv;
@@
-131,8
+150,8
@@
public class NetAddress extends CommonBase {
* Utility method to constructs a new IPv6-variant NetAddress
*/
public static NetAddress ipv6(byte[] addr, short port) {
* Utility method to constructs a new IPv6-variant NetAddress
*/
public static NetAddress ipv6(byte[] addr, short port) {
- long ret = bindings.NetAddress_ipv6(
addr
, port);
- if (ret
< 1024
) { return null; }
+ long ret = bindings.NetAddress_ipv6(
InternalUtils.check_arr_len(addr, 16)
, port);
+ if (ret
>= 0 && ret <= 4096
) { return null; }
NetAddress ret_hu_conv = NetAddress.constr_from_ptr(ret);
ret_hu_conv.ptrs_to.add(ret_hu_conv);
return ret_hu_conv;
NetAddress ret_hu_conv = NetAddress.constr_from_ptr(ret);
ret_hu_conv.ptrs_to.add(ret_hu_conv);
return ret_hu_conv;
@@
-142,8
+161,8
@@
public class NetAddress extends CommonBase {
* Utility method to constructs a new OnionV2-variant NetAddress
*/
public static NetAddress onion_v2(byte[] addr, short port) {
* Utility method to constructs a new OnionV2-variant NetAddress
*/
public static NetAddress onion_v2(byte[] addr, short port) {
- long ret = bindings.NetAddress_onion_v2(
addr
, port);
- if (ret
< 1024
) { return null; }
+ long ret = bindings.NetAddress_onion_v2(
InternalUtils.check_arr_len(addr, 10)
, port);
+ if (ret
>= 0 && ret <= 4096
) { return null; }
NetAddress ret_hu_conv = NetAddress.constr_from_ptr(ret);
ret_hu_conv.ptrs_to.add(ret_hu_conv);
return ret_hu_conv;
NetAddress ret_hu_conv = NetAddress.constr_from_ptr(ret);
ret_hu_conv.ptrs_to.add(ret_hu_conv);
return ret_hu_conv;
@@
-153,8
+172,8
@@
public class NetAddress extends CommonBase {
* Utility method to constructs a new OnionV3-variant NetAddress
*/
public static NetAddress onion_v3(byte[] ed25519_pubkey, short checksum, byte version, short port) {
* Utility method to constructs a new OnionV3-variant NetAddress
*/
public static NetAddress onion_v3(byte[] ed25519_pubkey, short checksum, byte version, short port) {
- long ret = bindings.NetAddress_onion_v3(
ed25519_pubkey
, checksum, version, port);
- if (ret
< 1024
) { return null; }
+ long ret = bindings.NetAddress_onion_v3(
InternalUtils.check_arr_len(ed25519_pubkey, 32)
, checksum, version, port);
+ if (ret
>= 0 && ret <= 4096
) { return null; }
NetAddress ret_hu_conv = NetAddress.constr_from_ptr(ret);
ret_hu_conv.ptrs_to.add(ret_hu_conv);
return ret_hu_conv;
NetAddress ret_hu_conv = NetAddress.constr_from_ptr(ret);
ret_hu_conv.ptrs_to.add(ret_hu_conv);
return ret_hu_conv;
@@
-173,7
+192,7
@@
public class NetAddress extends CommonBase {
*/
public static Result_NetAddressDecodeErrorZ read(byte[] ser) {
long ret = bindings.NetAddress_read(ser);
*/
public static Result_NetAddressDecodeErrorZ read(byte[] ser) {
long ret = bindings.NetAddress_read(ser);
- if (ret
< 1024
) { return null; }
+ if (ret
>= 0 && ret <= 4096
) { return null; }
Result_NetAddressDecodeErrorZ ret_hu_conv = Result_NetAddressDecodeErrorZ.constr_from_ptr(ret);
return ret_hu_conv;
}
Result_NetAddressDecodeErrorZ ret_hu_conv = Result_NetAddressDecodeErrorZ.constr_from_ptr(ret);
return ret_hu_conv;
}