I need to create a WiFi hotspot using ESP32 which is connected to an existing WiFi network.
How to create a hotspot using ESP32 in Mongoose OS?
You can try by creating conf1.json in fs folder. In that conf1.json file write all configuration of station also enable access point mode.
fs/conf1.json
"wifi": {
"sta": {
"enable": true, // Enable Station mode
"ssid": "", // WiFi network name
"pass": "", // Password
"user": "", // Username for WPA-PEAP mode
"anon_identity": "", // Anonymous identity for WPA mode
"cert": "", // Client certificate for WPA-TTLS mode
"key": "", // Client key for WPA-TTLS mode
"ca_cert": "", // CA certificate for WPA-enterprise mode
"ip": "", // Static IP Address
"netmask": "", // Static Netmask
"gw": "", // Static Default Gateway
"nameserver": "", // DNS Server
"dhcp_hostname": "" // Host name to include in DHCP requests
},
"ap": {
"enable": true, // Enable Access Point mode
"ssid": "Mongoose_??????", // SSID to use. ?? symbols are substituted by MAC address
"pass": "Mongoose", // Password
"hidden": false, // Hide WiFi network
"channel": 6, // WiFi channel
"max_connections": 10, // Maximum number of connections
"ip": "192.168.4.1", // Static IP Address
"netmask": "255.255.255.0", // Static Netmask
"gw": "192.168.4.1", // Static Default Gateway
"dhcp_start": "192.168.4.2", // DHCP Start Address
"dhcp_end": "192.168.4.100", // DHCP End Address
"trigger_on_gpio": -1 // Trigger AP on low GPIO
}
}
Related
I am running Nginx on ECS Fargate with below config to implement a passthrough TLS proxy. I am getting intermittent errors - upstream server temporarily disabled while proxying connection in some of the AWS regions. The backend domain is an API Gateway domain.
stream {
map_hash_max_size 256;
map_hash_bucket_size 256;
map $ssl_preread_protocol $tlsmap {
"TLSv1.2" $upstream;
"TLSv1.3" $upstream;
default blackhole;
}
map $ssl_preread_server_name $upstream {
<api_domain> api_domain;
default blackhole;
}
upstream api_domain {
server api_domain:443;
}
upstream blackhole {
server 127.0.0.1:123;
}
server {
listen 443;
proxy_pass $tlsmap;
ssl_preread on;
}
}
Below is the nginx log for the request:
{
"time_local": "<removed>",
"remote_addr": "<removed>",
"remote_port": "24907",
"ssl_preread_server_name": "<removed>",
"ssl_preread_protocol": "TLSv1.2",
"status": "200",
"bytes_sent": "0",
"bytes_received": "0",
"session_time": "60.012",
"upstream_addr": "<removed>",
"upstream_bytes_sent": "0, 517",
"upstream_bytes_received": "0, 0",
"upstream_connect_time": "-, 0.000",
"connection": "85860",
"ssl_protocol": "",
"ssl_cipher": ""
}
Any pointers on what configuration can be fine tuned to fix this ?
I'm using the Network Extension framework provided by Apple to build a packet sniffing/monitoring application similar to Charles Proxy and Surge 4 for iOS.
So far, I have the basic structure of the project up and running with the Main Application triggering the PacketTunnelProvider Extension where I can see packets being forwarded via the packetFlow.readPackets(completionHandler:) method. My background isn't in networking so I'm confused on the basic structure of these kinds of apps. Do they host a server on the device that act as the proxy which intercepts network requests? Could anyone provide a diagram of the general flow of the network requests? I.e. what is the relationship between the Packet Tunnel Provider, Proxy Server, Virtual Interface, and Tunnel?
If these apps do use a local on-device server, how do you configure the NEPacketTunnelNetworkSettings to allow for a connection? I have tried incorporating a local on-device server such as GCDWebServer with no luck in establishing a link between the two.
For example, if the GCDWebServer was reachable at 192.168.1.231:8080, how would I change the code below for the client to communicate with the server?
Main App:
let proxyServer = NEProxyServer(address: "192.168.1.231", port: 8080)
let proxySettings = NEProxySettings()
proxySettings.exceptionList = []
proxySettings.httpEnabled = true
proxySettings.httpServer = proxyServer
let providerProtocol = NETunnelProviderProtocol()
providerProtocol.providerBundleIdentifier = self.tunnelBundleId
providerProtocol.serverAddress = "My Server"
providerProtocol.providerConfiguration = [:]
providerProtocol.proxySettings = proxySettings
let newManager = NETunnelProviderManager()
newManager.localizedDescription = "Custom VPN"
newManager.protocolConfiguration = providerProtocol
newManager.isEnabled = true
saveLoadManager()
self.vpnManager = newManager
PacketTunnelProviderExtension:
func startTunnel(options: [String : NSObject]?, completionHandler: #escaping (Error?) -> Void) {
...
let settings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "127.0.0.143")
settings.ipv4Settings = NEIPv4Settings(addresses: ["198.17.203.2"], subnetMasks: ["255.255.255.255"])
settings.ipv4Settings?.includedRoutes = [NEIPv4Route.default()]
settings.ipv4Settings?.excludedRoutes = []
settings.dnsSettings = NEDNSSettings(servers: ["8.8.8.8", "8.8.4.4"])
settings.dnsSettings?.matchDomains = [""]
self.setTunnelNetworkSettings(settings) { error in
if let e = error {
NSLog("Settings error %#", e.localizedDescription)
} else {
completionHandler(error)
self.readPackets()
}
}
...
}
I'm working on the iOS version of Proxyman and my experience can help you:
Do they host a server on the device that acts as the proxy which intercepts network requests?
Yes, you have to start a Listener on the Network Extension (not the main app) to act as a Proxy Server. You can write a simple Proxy Server by using Swift NIO or CocoaAsyncSocket.
To intercept the HTTPS traffic, it's a quite big challenge, but I won't mention here since it's out of the scope.
Could anyone provide a diagram of the general flow of the network requests?
As the Network Extension and the Main app are two different processes, so they couldn't communicate directly like normal apps.
Thus, the flow may look like:
The Internet -> iPhone -> Your Network Extension (VPN) -> Forward to your Local Proxy Server -> Intercept or monitor -> Save to a local database (in Shared Container Group) -> Forward again to the destination server.
From the main app, you can receive the data by reading the local database.
how do you configure the NEPacketTunnelNetworkSettings to allow for a connection?
In the Network extension, let start a Proxy Server at Host:Port, then init the NetworkSetting, like the sample:
private func initTunnelSettings(proxyHost: String, proxyPort: Int) -> NEPacketTunnelNetworkSettings {
let settings: NEPacketTunnelNetworkSettings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "127.0.0.1")
/* proxy settings */
let proxySettings: NEProxySettings = NEProxySettings()
proxySettings.httpServer = NEProxyServer(
address: proxyHost,
port: proxyPort
)
proxySettings.httpsServer = NEProxyServer(
address: proxyHost,
port: proxyPort
)
proxySettings.autoProxyConfigurationEnabled = false
proxySettings.httpEnabled = true
proxySettings.httpsEnabled = true
proxySettings.excludeSimpleHostnames = true
proxySettings.exceptionList = [
"192.168.0.0/16",
"10.0.0.0/8",
"172.16.0.0/12",
"127.0.0.1",
"localhost",
"*.local"
]
settings.proxySettings = proxySettings
/* ipv4 settings */
let ipv4Settings: NEIPv4Settings = NEIPv4Settings(
addresses: [settings.tunnelRemoteAddress],
subnetMasks: ["255.255.255.255"]
)
ipv4Settings.includedRoutes = [NEIPv4Route.default()]
ipv4Settings.excludedRoutes = [
NEIPv4Route(destinationAddress: "192.168.0.0", subnetMask: "255.255.0.0"),
NEIPv4Route(destinationAddress: "10.0.0.0", subnetMask: "255.0.0.0"),
NEIPv4Route(destinationAddress: "172.16.0.0", subnetMask: "255.240.0.0")
]
settings.ipv4Settings = ipv4Settings
/* MTU */
settings.mtu = 1500
return settings
}
Then start a VPN,
let networkSettings = initTunnelSettings(proxyHost: ip, proxyPort: port)
// Start
setTunnelNetworkSettings(networkSettings) { // Handle success }
Then forward the package to your local proxy server:
let endpoint = NWHostEndpoint(hostname: proxyIP, port: proxyPort)
self.connection = self.createTCPConnection(to: endpoint, enableTLS: false, tlsParameters: nil, delegate: nil)
packetFlow.readPackets {[weak self] (packets, protocols) in
guard let strongSelf = self else { return }
for packet in packets {
strongSelf.connection.write(packet, completionHandler: { (error) in
})
}
// Repeat
strongSelf.readPackets()
}
From that, your local server can receive the packages then forwarding to the destination server.
While running the testcases through jenkins on ec2 instance,I am getting error message.
Here's my nightwatch configuration:
{
"src_folders" : ["test"],
"globals_path": "globals.js",
"output_folder" : "reports",
"custom_commands_path" : "./commands",
"custom_assertions_path" : "./assertions",
"page_objects_path":"./pages",
"test_workers" : {
"enabled" : false,
"workers" : "auto"
},
"selenium" : {
"start_process" : true,
"server_path" : "./bin/selenium-server-standalone-4.0.0.jar",
"log_path" : "",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "./bin/chromedriver_linux"
}
},
"test_settings" : {
"default" : {
"request_timeout_options": {
"timeout": 100000
},
"videos": {
"enabled": false,
"delete_on_pass": false,
"path": "reports/videos",
"format": "mp4",
"resolution": "1280x720",
"fps": 15,
"display": ":",
"pixel_format": "yuv420p",
"inputFormat": "mjpeg"
},
"launch_url" : "http://localhost",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"screenshots" : {
"enabled" : false,
"on_failure" : true,
"on_error" : true,
"path" : "./screenshots"
},
"end_session_on_fail" : true,
"skip_testcases_on_fail" : false,
"use_xpath" : true,
"globals" : {
"url" : "http://ec30-3-100-2-16.us-north-10.compute.amazonws.com:1000/login"
},
"desiredCapabilities": {
"browserName": "chrome",
"chromeOptions": {
"w3c": false,
"args" : ["headless","no-sandbox"]
},
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}
getting below error message in the console :
Login Test Test Suite
==========================
- Connecting to localhost on port 4444...
Connected to localhost on port 4444 (31794ms).
Using: chrome (81.0.4044.129) on Linux platform.
Running: Verify user is able to login
POST /wd/hub/session/2a3ca3b508f6dda4d0933225c41824a4/url - ECONNRESET
Error: socket hang up
at connResetException (internal/errors.js:604:14)
at Socket.socketCloseListener (_http_client.js:400:25)
Error while running .navigateTo() protocol action: An unknown error has occurred.
POST /wd/hub/session/2a3ca3b508f6dda4d0933225c41824a4/elements - ECONNRESET
Error: socket hang up
at connResetException (internal/errors.js:604:14)
at Socket.socketCloseListener (_http_client.js:400:25)
Error while running .locateMultipleElements() protocol action: An unknown error has occurred.
I have installed the chrome browser(81.0.4044.129) in ec2 instance and their respective chrome linux driver
selenium server : selenium-server-standalone-4.0.0.jar
Note:
I configured the Jenkins in my local machine(MAC OS) and its working fine.
Please let me know if you need more information.
I believe you security group attached to the EC2 server doesn't have ICMP IPV4 inbound rules accessible to your server running this nightwatch script. Try adding your nightwatch server IP address in the ICMP IPV4 inbound rules of the ec2 server you provided in the URL or you can even make it publicly accessible. I hope this resolves your issue.
I have setup a single master with 2 client endpoints in my icintga2 monitoring system using director with Top-Down mode.
I have also setup 2 client nodes with both accept configs and accept commands.
(hopefully this means I'm running Top Down Command Endpoint mode)
The service checks (disk/mem/load) for the 3 hosts are returning correct results. But my problem is:
according to the example from Top Down Command Endpoint example,
host icinga2-client1 is using "hostalive" as the host check_command.
eg.
object Host "icinga2-client1.localdomain" {
check_command = "hostalive" //check is executed on the master
address = "192.168.56.111"
vars.client_endpoint = name //follows the convention that host name == endpoint name
}
But one issue I have is that
if the client1 icinga process is not running,
the host status stays GREEN and also all of service status (disk/mem/load) stay all GREEN as well
because master is not getting any service check updates and hostalive check command is able to ping the node.
Under Best Practice - Health Check section,
it mentioned to use "cluster-zone" check commands.
I was expecting while using "cluster-zone",
the host status would be RED
when the client node icinga process is stopped,
but somehow this is not happening.
Does anyone has any idea?
My zone/host/endpoint configurations are as follows:
object Zone "icinga-master" {
endpoints = [ "icinga-master" ]
}
object Host "icinga-master" {
import "Master-Template"
display_name = "icinga-master [192.168.100.71]"
address = "192.168.100.71"
groups = [ "Servers" ]
}
object Endpoint "icinga-master" {
host = "192.168.100.71"
port = "5665"
}
object Zone "rick-tftp" {
parent = "icinga-master"
endpoints = [ "rick-tftp" ]
}
object Endpoint "rick-tftp" {
host = "172.16.181.216"
}
object Host "rick-tftp" {
import "Host-Template"
display_name = "rick-tftp [172.16.181.216]"
address = "172.16.181.216"
groups = [ "Servers" ]
vars.cluster_zone = "icinga-master"
}
object Zone "tftp-server" {
parent = "icinga-master"
endpoints = [ "tftp-server" ]
}
object Endpoint "tftp-server" {
host = "192.168.100.221"
}
object Host "tftp-server" {
import "Host-Template"
display_name = "tftp-server [192.168.100.221]"
address = "192.168.100.221"
groups = [ "Servers" ]
vars.cluster_zone = "icinga-master"
}
template Host "Host-Template" {
import "pnp4nagios-host"
check_command = "cluster-zone"
max_check_attempts = "5"
check_interval = 1m
retry_interval = 30s
enable_notifications = true
enable_active_checks = true
enable_passive_checks = true
enable_event_handler = true
enable_perfdata = true
}
Thanks,
Rick
I want to set my wifi hotspot password programmatically for my application so that user don't have to go to the setting menu to check their password.
I am already using NEHotspotNetwork, where it set the password, but here, we need to set the password which is already there in the setting menu for connecting to the network.
It's also helpful if I can get my wifi hotspot password, from the application without jailbreak my device.
You just need to use the following code:
WifiConfiguration netConfig = new WifiConfiguration();
netConfig .preSharedKey = "yourpassword";
Using NEHotspotNetwork function register you can set the password
NEHotspotHelper.register(options: options, queue: queue) { (cmd: NEHotspotHelperCommand) in
if cmd.commandType == NEHotspotHelperCommandType.filterScanList {
//Get all available hotspots
var list: [NEHotspotNetwork] = cmd.networkList!
//Figure out the hotspot you wish to connect to
// let desiredNetwork : NEHotspotNetwork? = getBestScanResult(list)
var hotspot = [NEHotspotNetwork]()
for network in cmd.networkList!
{//check for your network ssid and set password
network.setConfidence(.high)
network.setPassword("yourpassword") //Set the WIFI password
hotspot.append(network)
}
let response = cmd.createResponse(NEHotspotHelperResult.success)
response.setNetworkList(hotspot)
response.deliver() } else if cmd.commandType == NEHotspotHelperCommandType.evaluate {
if let network = cmd.network {
let response = cmd.createResponse(NEHotspotHelperResult.success)
response.setNetwork(network)
response.deliver() //Respond back }
} else if cmd.commandType == NEHotspotHelperCommandType.authenticate {
//Perform custom authentication and respond back with success
// if all is OK
let response = cmd.createResponse(NEHotspotHelperResult.success)
response.deliver() //Respond back
}
Also you can use network configuration profile with the help of Apple Configurator 2 tool for your known network. There you need to setup your wi-fi and then after installing the NCP on your device, It will automatically connect with the mentioned network. But you have to host that file on server cause we can't download profile locally and using local server like GCDServer(tried already.)