Class CastLink
java.lang.Object
com.iizigo.panel.CastLink
The link of "Show QR code for iiziRun Developer" in the Panel Editor's Cast to Device drop-down, and the addresses of this computer it can carry. Nothing here has a user interface, so that the address filter and the link are tested without a window (
CastQRWindow shows them).The link opens Cast to Device of this iiziGo in iiziRun Developer: iizirundev://ca?addr=<address>&port=<port>, the parameter style of iiziRun's run and define links, the values percent-encoded as JavaScript's encodeURIComponent encodes them, HTTP only (no ssl), no pairing token (rulings QL-D-1, QL-D-8, QL-D-10 of 2026-10-14). The port is the one the Designer's web server really holds, read from the running server.
The address filter (QL-D-2, QL-D-11). Every address of every interface of this computer is offered, IPv4 and IPv6, except:
- an interface that is down, a loopback interface, a point-to-point interface (a VPN or dial-up link), an interface without a hardware address (tunnels and pseudo interfaces), and an interface whose hardware address belongs to a virtual machine vendor (Hyper-V, VMware, VirtualBox, Parallels, Xen, QEMU, Docker: OSHI's
isKnownVmMacAddr, the libraryHardwareInforeads its network cards with) - a virtual switch's address is reachable from this computer only - unless that interface carries the default route: then this computer is itself a virtual machine, or its network goes through a virtual switch, and the phone may reach it; - a loopback, wildcard or multicast address, and a link-local address: IPv4
169.254.0.0/16and IPv6fe80::/10. A link-local IPv6 address needs its zone, which names an interface of this computer and which a WebView cannot use (CL-D-5 of CC-FIX-IIZIRUN-CAST-LINK, measured); - when the web server is bound to one address (Preferences > IIZI > Web server, or the
-Doverride), every address but that one.
- Author:
- Christopher Mindus
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAn address offered in the chooser.static final classA network interface as the address filter reads it: what the system says about it, and its addresses.Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe start of the link, up to and including the'?'of its query.Method Summary
Modifier and TypeMethodDescriptionstatic StringBuilds the link:iizirundev://ca?addr=<host>&port=<port>, the host percent-encoded.static BufferedImagecreateQRImage(String link, int size) Creates the QR code of a link (com.iizix.barcode), black on white.static StringencodeComponent(String value) Percent-encodes a value as JavaScript'sencodeURIComponentdoes, which iiziRun'sdecodeURIComponentreverses: the letters, digits and-_.!~*'()as they are, every other character as the%XXof its UTF-8 bytes (upper-case hexadecimal).static List<CastLink.Interface> Enumerates the interfaces of this computer: the flags and addresses fromNetworkInterface, the virtual machine test, the kind and the name a user knows from OSHI (the libraryHardwareInfouses), and the interface of the default route (getDefaultRouteSources()).static List<InetAddress> Gets the addresses this computer sends from on its default routes, IPv4 and IPv6: the local address of a UDP socket connected to a documentation address (192.0.2.1,2001:db8::1).static intGets the HTTP port the Designer's web server really holds, read from the running server.static StringhostOf(InetAddress address) Gets the text of an address as the link carries it: an IPv4 address in dotted form; an IPv6 address in its short form (RFC 5952: lower case, no leading zeros, the longest run of two or more zero groups as::), without brackets and without a zone.static booleanisOfferedAddress(InetAddress address) Tells whether an address may be offered at all, whatever its interface: not a loopback, wildcard, multicast or link-local address (IPv4169.254.0.0/16, IPv6fe80::/10).static List<CastLink.Address> offer(List<CastLink.Interface> interfaces, Collection<InetAddress> bound) Gets the addresses to offer, by the filter of this class: IPv4 first, then IPv6, each in the order of the interfaces.static List<CastLink.Address> Gets the addresses of this computer to offer:enumerate()throughoffer(List,Collection), with the bind address of the web server in effect (the preference, or the-Doverride).static List<InetAddress> resolveBind(String bind) Gets the addresses the web server is bound to.
Field Details
LINK_PREFIX
The start of the link, up to and including the'?'of its query.- See Also:
Method Details
isOfferedAddress
Tells whether an address may be offered at all, whatever its interface: not a loopback, wildcard, multicast or link-local address (IPv4169.254.0.0/16, IPv6fe80::/10).- Parameters:
address- The address.- Returns:
truewhen a phone on the same network may reach it.
offer
public static List<CastLink.Address> offer(List<CastLink.Interface> interfaces, Collection<InetAddress> bound) Gets the addresses to offer, by the filter of this class: IPv4 first, then IPv6, each in the order of the interfaces.- Parameters:
interfaces- The interfaces.bound- The addresses the web server is bound to, null or empty when it is bound to all of them.- Returns:
- The addresses, a new list (empty when nothing can be offered).
resolveBind
Gets the addresses the web server is bound to.- Parameters:
bind- The bind address of the web server: null, empty,0.0.0.0or::for all.- Returns:
- The addresses, empty for all; an address that cannot be resolved gives a list holding nothing that matches, so that nothing is offered.
offerOfThisComputer
Gets the addresses of this computer to offer:enumerate()throughoffer(List,Collection), with the bind address of the web server in effect (the preference, or the-Doverride).- Returns:
- The addresses, a new list (empty when nothing can be offered).
enumerate
Enumerates the interfaces of this computer: the flags and addresses fromNetworkInterface, the virtual machine test, the kind and the name a user knows from OSHI (the libraryHardwareInfouses), and the interface of the default route (getDefaultRouteSources()). When OSHI cannot be used, an interface has no kind and is not taken for a virtual machine's.- Returns:
- The interfaces, a new list.
getDefaultRouteSources
Gets the addresses this computer sends from on its default routes, IPv4 and IPv6: the local address of a UDP socket connected to a documentation address (192.0.2.1,2001:db8::1). Connecting a UDP socket only chooses the route; nothing is sent.- Returns:
- The addresses, none when there is no default route.
getServerPort
public static int getServerPort()Gets the HTTP port the Designer's web server really holds, read from the running server.- Returns:
- The port, 0 when the web server is not running.
hostOf
Gets the text of an address as the link carries it: an IPv4 address in dotted form; an IPv6 address in its short form (RFC 5952: lower case, no leading zeros, the longest run of two or more zero groups as::), without brackets and without a zone.- Parameters:
address- The address.- Returns:
- The text.
buildLink
Builds the link:iizirundev://ca?addr=<host>&port=<port>, the host percent-encoded.- Parameters:
host- The address ashostOf(InetAddress)gives it, or a host name.port- The HTTP port.- Returns:
- The link.
encodeComponent
Percent-encodes a value as JavaScript'sencodeURIComponentdoes, which iiziRun'sdecodeURIComponentreverses: the letters, digits and-_.!~*'()as they are, every other character as the%XXof its UTF-8 bytes (upper-case hexadecimal).- Parameters:
value- The value.- Returns:
- The encoded value.
createQRImage
Creates the QR code of a link (com.iizix.barcode), black on white.- Parameters:
link- The link.size- The width and height in pixels (the code may be made larger to fit).- Returns:
- The image.
- Throws:
BarcodeException- If the code cannot be made.