Skip to content

Commit

Permalink
Merge branch 'dev-0.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
birdofpreyru committed May 31, 2023
2 parents cab1177 + 4ecf9bf commit a13f16a
Show file tree
Hide file tree
Showing 25 changed files with 967 additions and 680 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPCRE2_CODE_UNIT_WIDTH=8 -I${CMAKE_BINARY_D
add_subdirectory(lighttpd1.4)

file(WRITE ${CMAKE_BINARY_DIR}/lighttpd1.4/build/plugin-static.h
PLUGIN_INIT(mod_indexfile)\n
PLUGIN_INIT(mod_dirlisting)\n
PLUGIN_INIT(mod_h2)\n
PLUGIN_INIT(mod_indexfile)\n
PLUGIN_INIT(mod_staticfile)\n
)
34 changes: 18 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ and [old][Old Architecture] RN architectures.
<td width="141px">
<img
alt="Luna4 Enterprises Inc."
width="141"
height="70"
width="100%"
height="auto"
src="https://raw.githubusercontent.com/birdofpreyru/react-native-static-server/master/.README/logo-luna4.png"
>
</td>
Expand Down Expand Up @@ -395,9 +395,9 @@ within `options` argument:
- `hostname` &mdash; **string** &mdash; Optional. Sets the address for server
to bind to.
- By default, if `nonLocal` option is **false**, `hostname` is set equal
"`localhost`" &mdash; the server binds to the localhost (127.0.0.1)
loopback address, and it is accessible only from within the host app.
- By default, when `nonLocal` option is **false**, `hostname` is set equal
"`127.0.0.1`" &mdash; the server binds to the loopback address,
and it is accessible only from within the host app.
- If `nonLocal` option is **true**, and `hostname` was not given, it is
initialized with empty string, and later assigned to a library-selected
non-local IP address, at the first launch of the server.
Expand All @@ -409,11 +409,12 @@ within `options` argument:
appropriate non-local address._
- `nonLocal` &mdash; **boolean** &mdash; Optional. By default, if `hostname`
option was not provided, the server starts at the "`localhost`" address,
and it is only accessible within the host app. With this flag set **true**
the server will be started on an IP adress also accessible from outside the app.
option was not provided, the server starts at the "`127.0.0.1`" (loopback)
address, and it is only accessible within the host app.
With this flag set **true** the server will be started on an IP address
also accessible from outside the app.
_NOTE: When `hostname` option is set to a value different from "`localhost`",
_NOTE: When `hostname` option is provided,
the `nonLocal` option is ignored. The plan is to deprecate `nonLocal` option
in future, in favour of special `hostname` values supporting the current
`nonLocal` functionality._
Expand Down Expand Up @@ -555,12 +556,13 @@ on target device from which static assets are served by the server.
```ts
server.hostname: string;
```
Readonly property. It holds hostname used by the server. If server instance
was constructed without `nonLocal` option (default), the `.hostname` property
will equal "`localhost`" from the beginning. Otherwise, it will be empty string
till the first launch of server instance, after which it will be equal to IP
address automatically selected for the server. This IP address won't change
upon subsequent re-starts of the server.
Readonly property. It holds the hostname used by the server. If no `hostname`
value was provided to the server's [constructor()], this property will be:
- Without `nonLocal` option it will be equal `127.0.0.1` (the loopback address)
from the very beginning;
- Otherwise, it will be an empty string until the first launch of the server
instance, after which it will become equal to the IP address selected by
the server automatically, and won't change upon subsequent server re-starts.
#### .id
[.id]: #id
Expand Down Expand Up @@ -816,7 +818,7 @@ See [OLD-README.md]
what folder is served by default).
- `nonLocal` option replaces the old `localOnly` option, with the opposite
meaning and default behavior. Now, by default the server is started on
"`localhost`" and is only accessible from within the app. Setting `nonLocal`
"`127.0.0.1`" (the loopback address) and is only accessible from within the app. Setting `nonLocal`
flag will start it on an automatically assigned IP, accessible from outside
the app as well. This is the opposite to behavior in previous versions, and
it feels more secure (prevents exposing server outside the app due to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void getLocalIpAddress(Promise promise) {
}
}
}
promise.resolve("localhost");
promise.resolve("127.0.0.1");
} catch (Exception e) {
Errors.FAIL_GET_LOCAL_IP_ADDRESS.reject(promise);
}
Expand Down Expand Up @@ -135,9 +135,10 @@ public void accept(String signal, String details) {
}

@ReactMethod
public void getOpenPort(Promise promise) {
public void getOpenPort(String address, Promise promise) {
try {
ServerSocket socket = new ServerSocket(0);
ServerSocket socket = new ServerSocket(
0, 0, InetAddress.getByName(address));
int port = socket.getLocalPort();
socket.close();
promise.resolve(port);
Expand Down
2 changes: 1 addition & 1 deletion android/src/oldarch/ReactNativeStaticServerSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public abstract void start(
double id, String configPath, String errlogPath, Promise promise);

public abstract void getLocalIpAddress(Promise promise);
public abstract void getOpenPort(Promise promise);
public abstract void getOpenPort(String address, Promise promise);
public abstract void stop(Promise promise);
}
33 changes: 26 additions & 7 deletions dr-pogodin-react-native-static-server.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,31 @@ Pod::Spec.new do |s|
s.script_phase = {
:name => 'Build native dependencies',
:execution_position => :before_compile,
# TODO: This should be re-added, but maybe different sets of files.
#:output_files => [
# '${BUILT_PRODUCTS_DIR}/libpcre2-8.a',
# '${BUILT_PRODUCTS_DIR}/iblighttpd.a'
# It also depends on compiled module files!
#],
:output_files => [
# Note: Below is the list of all build products generated from PRCE2,
# Lighttpd, and this library, as of now; the commented out modules are
# not currently used by our library.
'${BUILT_PRODUCTS_DIR}/liblighttpd.a',
# '${BUILT_PRODUCTS_DIR}/libmod_accesslog.a',
# '${BUILT_PRODUCTS_DIR}/libmod_ajp13.a',
# '${BUILT_PRODUCTS_DIR}/libmod_auth.a',
# '${BUILT_PRODUCTS_DIR}/libmod_authn_file.a',
# '${BUILT_PRODUCTS_DIR}/libmod_cgi.a',
# '${BUILT_PRODUCTS_DIR}/libmod_deflate.a',
'${BUILT_PRODUCTS_DIR}/libmod_dirlisting.a',
# '${BUILT_PRODUCTS_DIR}/libmod_extforward.a',
'${BUILT_PRODUCTS_DIR}/libmod_h2.a',
# '${BUILT_PRODUCTS_DIR}/libmod_proxy.a',
# '${BUILT_PRODUCTS_DIR}/libmod_rrdtool.a',
# '${BUILT_PRODUCTS_DIR}/libmod_sockproxy.a',
# '${BUILT_PRODUCTS_DIR}/libmod_ssi.a',
# '${BUILT_PRODUCTS_DIR}/libmod_status.a',
# '${BUILT_PRODUCTS_DIR}/libmod_userdir.a',
# '${BUILT_PRODUCTS_DIR}/libmod_vhostdb.a',
# '${BUILT_PRODUCTS_DIR}/libmod_webdav.a',
# '${BUILT_PRODUCTS_DIR}/libmod_wstunnel.a',
'${BUILT_PRODUCTS_DIR}/libpcre2-8.a'
],
:script => <<-CMD
set -e
Expand All @@ -53,7 +72,7 @@ Pod::Spec.new do |s|
CMD
}

$otherLibToolFlags = "-llighttpd -lpcre2-8 -lmod_dirlisting"
$otherLibToolFlags = "-llighttpd -lpcre2-8 -lmod_dirlisting -lmod_h2"

# Don't install the dependencies when we run `pod install` in the old architecture.
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
Expand Down
8 changes: 4 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PODS:
- boost (1.76.0)
- DoubleConversion (1.1.6)
- dr-pogodin-react-native-static-server (0.7.11):
- dr-pogodin-react-native-static-server (0.7.12):
- React-Core
- FBLazyVector (0.71.8)
- FBReactNativeSpec (0.71.8):
Expand Down Expand Up @@ -268,7 +268,7 @@ PODS:
- React-jsinspector (0.71.8)
- React-logger (0.71.8):
- glog
- react-native-webview (12.0.2):
- react-native-webview (12.1.0):
- React-Core
- React-perflogger (0.71.8)
- React-RCTActionSheet (0.71.8):
Expand Down Expand Up @@ -488,7 +488,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
boost: 57d2868c099736d80fcd648bf211b4431e51a558
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
dr-pogodin-react-native-static-server: f407ee9d08b9575532876f72f2ab3b231764c60f
dr-pogodin-react-native-static-server: b9ede861e83ec08d733fc73b5c1c644672c44d0f
FBLazyVector: f637f31eacba90d4fdeff3fa41608b8f361c173b
FBReactNativeSpec: 0d9a4f4de7ab614c49e98c00aedfd3bfbda33d59
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
Expand All @@ -509,7 +509,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: 747911ab5921641b4ed7e4900065896597142125
React-jsinspector: c712f9e3bb9ba4122d6b82b4f906448b8a281580
React-logger: 342f358b8decfbf8f272367f4eacf4b6154061be
react-native-webview: 203b6a1c7507737f777c91d7e10c30e7e67c1a17
react-native-webview: 13db17f7c7fe8f91c826e9afcc369cbc74507ea0
React-perflogger: d21f182895de9d1b077f8a3cd00011095c8c9100
React-RCTActionSheet: 0151f83ef92d2a7139bba7dfdbc8066632a6d47b
React-RCTAnimation: 5ec9c0705bb2297549c120fe6473aa3e4a01e215
Expand Down
2 changes: 1 addition & 1 deletion example/ios/ReactNativeStaticServerExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<key>127.0.0.1</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
Expand Down
Loading

0 comments on commit a13f16a

Please sign in to comment.