From 27bf47ec0d79605914bff000200bf6df6ddd63b3 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sun, 7 Apr 2024 03:47:36 +0300 Subject: [PATCH 1/9] fix variable name --- src/Resolve.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resolve.php b/src/Resolve.php index 933fa68..16f6d7e 100644 --- a/src/Resolve.php +++ b/src/Resolve.php @@ -179,7 +179,7 @@ class Resolve { if (\Yggverse\Net\Valid::ip6($host)) { - $resolved->setHost( + $address->setHost( sprintf( '[%s]', $host From 5e17d402451b0744fe8a73816e0b441a14846763 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sun, 7 Apr 2024 21:00:17 +0300 Subject: [PATCH 2/9] update readme --- README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index d08367b..102f5b6 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Network Library for PHP with native Yggdrasil support #### Check socket is open -``` +``` php var_dump( \Yggverse\Net\Socket::isOpen('yo.index', 80) ); @@ -20,7 +20,7 @@ var_dump( #### Check host valid -``` +``` php var_dump( \Yggverse\Net\Socket::isHost('yo.index') ); @@ -28,7 +28,7 @@ var_dump( #### Check port valid -``` +``` php var_dump( \Yggverse\Net\Socket::isPort(80) ); @@ -38,7 +38,7 @@ var_dump( #### Resolve records -``` +``` php var_dump( \Yggverse\Net\Dig::records('yo.index', ['A', 'AAAA'], &$result = [], &$error = [], $provider = null, $timeout = 5) ); @@ -46,7 +46,7 @@ var_dump( #### Check hostname valid -``` +``` php var_dump( \Yggverse\Net\Dig::isHostName('yo.index') ); @@ -54,7 +54,7 @@ var_dump( #### Check record valid -``` +``` php var_dump( \Yggverse\Net\Dig::isRecord('A') ); @@ -62,7 +62,7 @@ var_dump( #### Check record value valid -``` +``` php var_dump( \Yggverse\Net\Dig::isRecordValue('A', '127.0.0.1') ); @@ -72,7 +72,7 @@ var_dump( #### Init resolver -``` +``` php $resolve = new \Yggverse\Net\Resolve( [ 'A', @@ -88,7 +88,7 @@ $resolve = new \Yggverse\Net\Resolve( #### Get resolved URL string -``` +``` php $resolved = $resolve->url( 'https://en.wikipedia.org/wiki/Domain_Name_System' // next arguments contain debug variables and new address object @@ -104,7 +104,7 @@ if ($resolved) #### Resolve Address object -``` +``` php $resolved = $resolve->address( new \Yggverse\Net\Address( 'https://en.wikipedia.org/wiki/Domain_Name_System' @@ -144,7 +144,7 @@ Different operations with address parts: **Document root** -``` +``` php $base = new \Yggverse\Net\Address( 'http://yo.ygg/a1/b1/c1' ); @@ -162,7 +162,7 @@ var_dump( **Current folder** -``` +``` php $base = new \Yggverse\Net\Address( 'http://yo.ygg/a1/b1/c1' ); @@ -180,7 +180,7 @@ var_dump( **Ending slash** -``` +``` php $base = new \Yggverse\Net\Address( 'http://yo.ygg/a1/b1/c1/' ); @@ -198,7 +198,7 @@ var_dump( **All options** -``` +``` php $base = new \Yggverse\Net\Address( 'http://user:password@yo.ygg/a1/b1/c1?attribute=value#anchor' ); From 7c918ff99c19c3a6227b92f6c1a801d8394dd5c4 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sun, 7 Apr 2024 21:08:28 +0300 Subject: [PATCH 3/9] update readme --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 102f5b6..9419e8c 100644 --- a/README.md +++ b/README.md @@ -214,6 +214,17 @@ var_dump( ); ``` +### Valid + +Network entities validation + +**Supported methods** + +* `Valid::ip` +* `Valid::ip4` +* `Valid::ip6` +* `Valid::domainHostName` + ## Integrations * [Network API with native Yggdrasil/IPv6 support](https://github.com/YGGverse/web-api) From 4f369bac4555a8afd6a98bb22b01b584b713dfbb Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 9 Apr 2024 10:32:46 +0300 Subject: [PATCH 4/9] add integration --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9419e8c..a5da276 100644 --- a/README.md +++ b/README.md @@ -229,3 +229,4 @@ Network entities validation * [Network API with native Yggdrasil/IPv6 support](https://github.com/YGGverse/web-api) * [Yo! Crawler for different networks](https://github.com/YGGverse/Yo) +* [Yoda - PHP-GTK browser for Gemini Protocol](https://github.com/YGGverse/Yoda) From 0acff609f4feabdb52f65a15fcc668aad37369fa Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 16 Apr 2024 18:44:00 +0300 Subject: [PATCH 5/9] implement custom Address::get attributes --- src/Address.php | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/src/Address.php b/src/Address.php index f8b7e71..7ed5232 100644 --- a/src/Address.php +++ b/src/Address.php @@ -198,28 +198,37 @@ class Address $this->_separator = $value; } - public function get(): string + public function get( + bool $scheme = true, + bool $user = true, + bool $pass = true, + bool $host = true, + bool $port = true, + bool $path = true, + bool $query = true, + bool $fragment = true, + ): string { $address = ''; - if ($scheme = $this->getScheme()) + if ($scheme && $this->getScheme()) { $address .= sprintf( '%s:%s%s', - $scheme, + $this->getScheme(), $this->getSeparator(), $this->getSeparator() ); } - if ($user = $this->getUser()) + if ($user && $this->getUser()) { - if ($pass = $this->getPass()) + if ($pass && $this->getPass()) { $address .= sprintf( '%s:%s@', - $user, - $pass + $this->getUser(), + $this->getPass() ); } @@ -227,47 +236,47 @@ class Address { $address .= sprintf( '%s@', - $user + $this->getUser() ); } } - if ($host = $this->getHost()) + if ($host && $this->getHost()) { - $address .= $host; + $address .= $this->getHost(); } - if ($port = $this->getPort()) + if ($port && $this->getPort()) { $address .= sprintf( ':%d', - $port + $this->getPort() ); } - if ($path = $this->getPath()) + if ($path && $this->getPath()) { - if (!str_starts_with($path, $this->getSeparator())) + if (!str_starts_with($this->getPath(), $this->getSeparator())) { $address .= $this->getSeparator(); } - $address .= $path; + $address .= $this->getPath(); } - if ($query = $this->getQuery()) + if ($query && $this->getQuery()) { $address .= sprintf( '?%s', - $query + $this->getQuery() ); } - if ($fragment = $this->getFragment()) + if ($fragment && $this->getFragment()) { $address .= sprintf( '#%s', - $fragment + $this->getFragment() ); } From 0079e2a755789cc6e9c85b235644be2cc417b15c Mon Sep 17 00:00:00 2001 From: yggverse Date: Sun, 23 Jun 2024 00:17:31 +0300 Subject: [PATCH 6/9] replace getAbsolute with toAbsolute --- src/Address.php | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/Address.php b/src/Address.php index 7ed5232..d82756a 100644 --- a/src/Address.php +++ b/src/Address.php @@ -283,18 +283,18 @@ class Address return $address; } - public function getAbsolute( + public function toAbsolute( \Yggverse\Net\Address $base - ): ?string + ): bool { if ($this->isAbsolute()) { - return $this->get(); + return true; } if ($base->isRelative()) { - return null; + return false; } $this->setScheme( @@ -323,7 +323,7 @@ class Address if (str_starts_with((string) $this->getPath(), $this->getSeparator())) { - return $this->get(); + return true; } if ($path = $this->getPath()) @@ -351,7 +351,7 @@ class Address { if (empty($prefix[$index])) { - return null; + return false; } unset( @@ -377,8 +377,23 @@ class Address ) ) ); + + return true; } - return $this->get(); + return false; + } + + // @TODO deprecated, legacy needs only + public function getAbsolute( + \Yggverse\Net\Address $base + ): ?string + { + if ($this->toAbsolute($base)) + { + return $this->get(); + } + + return null; } } \ No newline at end of file From 9524c8fdec7443d8e27d47316787f1e84a7453d5 Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 24 Jun 2024 23:04:50 +0300 Subject: [PATCH 7/9] add new project integration --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a5da276..6703ebb 100644 --- a/README.md +++ b/README.md @@ -227,6 +227,7 @@ Network entities validation ## Integrations -* [Network API with native Yggdrasil/IPv6 support](https://github.com/YGGverse/web-api) -* [Yo! Crawler for different networks](https://github.com/YGGverse/Yo) -* [Yoda - PHP-GTK browser for Gemini Protocol](https://github.com/YGGverse/Yoda) +* [web-api](https://github.com/YGGverse/web-api) - Network API with native Yggdrasil/IPv6 support +* [Yo!](https://github.com/YGGverse/Yo) - Crawler and search engine for different networks +* [Yoda](https://github.com/YGGverse/Yoda) - Experimental PHP-GTK browser for Gemini protocol +* [gemini-dl](https://github.com/YGGverse/gemini-dl) - CLI downloader for Gemini protocol From b28658d0414431d8b1265c5a12cdd70c4990f0c3 Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 25 Jun 2024 00:10:36 +0300 Subject: [PATCH 8/9] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6703ebb..34b9e0c 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,7 @@ Network entities validation ## Integrations +* [gemini-dl](https://github.com/YGGverse/gemini-dl) - CLI batch downloader for Gemini protocol * [web-api](https://github.com/YGGverse/web-api) - Network API with native Yggdrasil/IPv6 support * [Yo!](https://github.com/YGGverse/Yo) - Crawler and search engine for different networks * [Yoda](https://github.com/YGGverse/Yoda) - Experimental PHP-GTK browser for Gemini protocol -* [gemini-dl](https://github.com/YGGverse/gemini-dl) - CLI downloader for Gemini protocol From 5ae447bcf0c0915aa9e1cb3ea45bc2b4aa78ddc9 Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 11 Jul 2024 10:10:13 +0300 Subject: [PATCH 9/9] fix absolute address detection --- src/Address.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Address.php b/src/Address.php index d82756a..41d19c6 100644 --- a/src/Address.php +++ b/src/Address.php @@ -83,7 +83,9 @@ class Address public function isAbsolute(): bool { - return ($this->_scheme && $this->_host); + return boolval( + $this->_scheme || $this->_host + ); } public function isRelative(): bool