How to set a user agent and use a proxy? - node-webkit

The documents read as follows:
user-agent
since v0.3.7
(string) Override the User-Agent header in HTTP requests made from the application.
The following placeholders are available:
%name: replaced by the name field in the manifest.
%ver: replaced by the version field in the manifest, if available.
%nwver: replaced by the version of node-webkit.
%webkit_ver: replaced by the version of WebKit engine.
%osinfo: replaced by the OS and CPU information you would see in browser's user agent string.
Can someone give me an example of how this implemented? eg. Current user agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 ...
Say I want to make it:
Chrome/5.0 (Windows NT) Chrome/35.0.1916 ...
Also, I'd like to use a proxy... is that possible within node-webkit?

User-Agent: In the package.json:
"name":"TheNameOfTheApp",
"version":"0.0.1",
"private":true,
"main":"index.html",
"dependencies":{
"express":"latest",
...
}
"window": {
"title": "MyApp",
"toolbar": true,
"frame": true,
"position": "center",
"fullscreen": false,
"resizable": true,
"width": 1000,
"height": 600,
"min_width": 600,
"min_height": 400
},
"user-agent":"%name NodeWebKit", //-> "TheNameOfTheApp NodeWebKit"
"node-remote": "<local>"

Related

How to create a window in tauri with kiosk mode? (mac os, windows os)

In electron, I can easily create a kiosk window by just adding a param kiosk: true.
But in tauri, is there any way to achieve that? I searched their official doc and couldn't find any.
Note: Here I'm referring to creating a window in fullscreen without topbar/ header and borders and it prevents the users to interact with other OS functionalities unless the user exists/ closes the app.
In tauri.conf.json you can find and modify window params like
"windows": [
{
"fullscreen": true,
"height": 600,
"resizable": true,
"title": "main",
"width": 800,
"alwaysOnTop": true,
"maximized": false,
"decorations": false
}
]
for mas details read this: https://tauri.app/v1/api/js/window/#windowmanager

Can't Connect to Service via Marathon-lb using DCOS

I recently went through the tutorial for load balancing apps in DCOS using marathon-lb (in the example they balance some nginx containers: https://dcos.io/docs/1.9/networking/marathon-lb/marathon-lb-advanced-tutorial/). I am trying to use this approach to internally load balance my own custom application. The custom app I am using is a play scala app. I have the internal marathon-lb set up and can successfully use it for the nginx container but when I try to use my own docker image I cannot get this to work. I start up my service with my custom image and I can access the service fine by using the IP and port that gets assigned to it (i.e. if the service gets deployed on 10.0.0.0 and is available on port 1234 then curl http://10.0.0.0:1234/ works as expected and I can also make my api calls as defined in my application routes). However, when I try to access the app through the load balancer (curl -i http://marathon-lb-internal.marathon.mesos:10002, where 10002 is the service port) then I get this message:
HTTP/1.0 503 Service Unavailable
Cache-Control: no-cache
Connection: close
Content-Type: text/html
<html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>
For reference, here is my json file I'm using to start my custom service:
{
"id": "my-app",
"container": {
"type": "DOCKER",
"docker": {
"image": "my_repo/my_image:1.0.0",
"network": "BRIDGE",
"portMappings": [
{ "hostPort": 0, "containerPort": 9000, "servicePort": 10002, "protocol": "tcp" }
],
"parameters": [
{ "key": "env", "value": "USER_NAME=user" },
{ "key": "env", "value": "USER_PASSWORD=password" }
],
"forcePullImage": true
}
},
"instances": 1,
"cpus": 1,
"mem": 1000,
"healthChecks": [{
"protocol": "HTTP",
"path": "/v1/health",
"portIndex": 0,
"timeoutSeconds": 10,
"gracePeriodSeconds": 10,
"intervalSeconds": 2,
"maxConsecutiveFailures": 10
}],
"labels":{
"HAPROXY_GROUP":"internal"
},
"uris": [ "https://s3.amazonaws.com/my_bucket/my_docker_credentials" ]
}
I had the same problem and found the solution here
marathon-lb health check failing on all spray.io containers
Need to add
"HAPROXY_0_BACKEND_HTTP_HEALTHCHECK_OPTIONS": " http-send-name-header Host\n timeout check {healthCheckTimeoutSeconds}s\n"
To your config so that the REST layer doesn't bark on the health check from marathon

OpenShift Aggregated Logging: Parse Apache access log

When using OpenShift Aggregated Logging I get logs nicely fed into elasticsearch. However, the line as logged by apache ends up in a message field.
I'd like to create queries in Kibana where I can access the url, the status code and other fields individually. For that the special apache access log parsing needs to be done.
How can I do that?
This is an example entry as seen in kibana:
{
"_index": "42-steinbruchsteiner-staging.3af0bedd-eebc-11e6-af4b-005056a62fa6.2017.03.29",
"_type": "fluentd",
"_id": "AVsY3aSK190OXhxv4GIF",
"_score": null,
"_source": {
"time": "2017-03-29T07:00:25.595959397Z",
"docker_container_id": "9f4fa85a626d2f5197f0028c05e8e42271db7a4c674cc145204b67b6578f3378",
"kubernetes_namespace_name": "42-steinbruchsteiner-staging",
"kubernetes_pod_id": "56c61b65-0b0e-11e7-82e9-005056a62fa6",
"kubernetes_pod_name": "php-app-3-weice",
"kubernetes_container_name": "php-app",
"kubernetes_labels_deployment": "php-app-3",
"kubernetes_labels_deploymentconfig": "php-app",
"kubernetes_labels_name": "php-app",
"kubernetes_host": "itsrv1564.esrv.local",
"kubernetes_namespace_id": "3af0bedd-eebc-11e6-af4b-005056a62fa6",
"hostname": "itsrv1564.esrv.local",
"message": "10.1.3.1 - - [29/Mar/2017:01:59:21 +0200] "GET /kwf/status/health HTTP/1.1" 200 2 "-" "Go-http-client/1.1"\n",
"version": "1.3.0"
},
"fields": {
"time": [
1490770825595
]
},
"sort": [
1490770825595
]
}
Disclaimer: I did not test this out in openshift. I don't know which tech stack you are using for your microservice.
This is how I do this in a spring boot application (with logback) deployed in Kubernetes.
1. Use logstash encoder for logback (This will write logs in Json format which is more ELK stack friendly)
I have a gradle dependency to enable this
compile "net.logstash.logback:logstash-logback-encoder:3.5"
Then configure LogstashEncoder as encoder in the appender, in logback-spring.groovy/logback-spring.xml (or logabck.xml)
2. Have some filters or libraries to write the access log
For 2. Either use
A. Use "net.rakugakibox.springbootext:spring-boot-ext-logback-access:1.6" library
(This is what I am using)
It gives in a nice json format, as follows
{
"#timestamp":"2017-03-29T09:43:09.536-05:00",
"#version":1,
"#message":"0:0:0:0:0:0:0:1 - - [2017-03-29T09:43:09.536-05:00] \"GET /orders/v1/items/42 HTTP/1.1\" 200 991",
"#fields.method":"GET",
"#fields.protocol":"HTTP/1.1",
"#fields.status_code":200,
"#fields.requested_url":"GET /orders/v1/items/42 HTTP/1.1",
"#fields.requested_uri":"/orders/v1/items/42",
"#fields.remote_host":"0:0:0:0:0:0:0:1",
"#fields.HOSTNAME":"0:0:0:0:0:0:0:1",
"#fields.content_length":991,
"#fields.elapsed_time":48,
"HOSTNAME":"ABCD"
}
OR
B. Use Logback's Tee Filter
OR
C. Spring's CommonsRequestLoggingFilter (Did not really test this out)
Add a bean definition
#Bean
public CommonsRequestLoggingFilter requestLoggingFilter() {
CommonsRequestLoggingFilter crlf = new CommonsRequestLoggingFilter();
crlf.setIncludeClientInfo(true);
crlf.setIncludeQueryString(true);
crlf.setIncludePayload(true);
return crlf;
}
Then set org.springframework.web.filter.CommonsRequestLoggingFilter to DEBUG, this can be done using the application.properties by adding:
logging.level.org.springframework.web.filter.CommonsRequestLoggingFilter=DEBUG

Phantom js won't open any pages

I'm trying to make Phantom JS load a page, but no matter what, it responds with an "operation canceled :( I've tried various versions settings that ignore ssl and various websites. But neither works.
I can reach all sites with a normal browser and run PhantomJS locally from a fully updated mac osx
./phantomjs --ignore-ssl-errors=true --ignore-ssl-errors=yes --ssl-protocol=tlsv1 ../../index.js http://askbar.dk
yelds
= onNavigationRequested
destination_url: http://askbar.dk/
type (cause): Other
will navigate: true
from page's main frame: true
= onResourceRequested()
request: {
"headers": [
{
"name": "Accept",
"value": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
},
{
"name": "User-Agent",
"value": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36"
}
],
"id": 1,
"method": "GET",
"time": "2016-04-11T20:05:39.998Z",
"url": "http://askbar.dk/"
}
= onNavigationRequested
destination_url: about:blank
type (cause): Other
will navigate: true
from page's main frame: true
http://askbar.dk/: Operation canceled
phantomjs://code/index.js:60 in onResourceError
= onResourceReceived()
id: 1, stage: "end", response: {"contentType":null,"headers":[],"id":1,"redirectURL":null,"stage":"end","status":null,"statusText":null,"time":"2016-04-11T20:05:39.999Z","url":"http://askbar.dk/"}
Any ideas ?

Xbmc Database Path

I am working with XBMC. I have installed XBMC in my system(Windows 7, 32 bit). Xbmc is working fine in my system. I have developed an application in order to control the Xbmc remotely from Ipad. In order to retrieve the music files or video files from Xbmc, I am unable to. By searching the forums of xbmc, I found that we can write an sql query to get them out. But, the thing is I am unable to make out where the database is located in my system. Someone help me out where I can find it.
Regards,
Sushma.
The database itself
By default the location of the database is that described on the wiki page XBMC databases
but the actual location can be changed by the user, or a different database technology can be used entirely.
The settings that would affect this are located in advancedsettings.xml.
But in general it is advised by the XBMC developers to never access the database directly.
JSONRPC
In order to help with interacting with the database XBMC has supported the JSONRPC queries, the one downside of these is that XBMC needs to be running at the time to respond to these queries. The major advantage is that it XBMC will find the database for you and expose access to it with a common interface.
JSONRPC support was first added to XBMC in "Darhma" (v10), became really useful in "Eden" (v11) and will support almost everything possible in "Frodo" (v12). Information about the use of JSONRPC can be found in the wiki.
An example
In this example I'm assuming that you are targeting "Eden", the current stable release of XBMC. Also I have formatted the following with new lines, these are not required and are not present in the response from XBMC.
Request
If you were to use JSONRPC the request you would need to send would look something like:
{
"jsonrpc": "2.0",
"method": "VideoLibrary.GetMovies",
"params": {
"properties": [
"title",
"year",
"file"
],
"limits": {
"start": 0,
"end": 2
}
},
"id": 1
}
Note: If you wanted different information about each movie you could use other properties listed here.
*Note: You probably want to omit the "limits" part to get all movies.*
Responce
The response to this would be something like:
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"limits": {
"end": 2,
"start": 0,
"total": 47
},
"movies": [
{
"label": "Label for movie",
"movieid": 1,
"title": "Title of movie",
"year": 2012
},
{
"label": "Label for another movie",
"movieid": 2,
"title": "Title of another movie",
"year": 2010
},
{
"label": "Label for a third movie",
"movieid": 3,
"title": "Title of a third movie",
"year": 2012
}
]
}
}
What to do now?
You have a choice at this point, you can either:
Add "file" to the list of properties, this will return the "file" property, the location of the video file.
Use JSONRPC to tell xbmc to play a movie.
Using this method is best when you don't want to play the file locally (on the iPad) but instead on XBMC.
Playing a movie on XBMC via JSONRPC
This is quite simple, use the "movieid" you received earlier in the following request:
{
"jsonrpc": "2.0",
"method": "Player.Open",
"params": {
"item": {
"movieid": 2
}
},
"id": 1
}
Lastly I would note that there are equivalent commands for TV episodes as shown for movies.