api design – How to intelligently discover and track significant changes in HTML with a C ++ / Qt backend, making it easier to extract and inject code?

Backstory (You can jump)

I work almost exclusively with Qt and with the design philosophy of

Expand everything as API

The particular practice of this question is the tracking of the members of the group, emitting signals whenever their value changes.

For example, here is a general way to treat class members with the philosophy of the API, namely that for each member, there are at least four components:

public:
QUrl url (); // return a copy of m_Url

public niches:
void setUrl (URL QUrl); // A designated URL creator

signals:
void urlChanged (); // emit a signal whenever setUrl () is used

private:
QUrl m_Url; // the object itself, with its protected state

This has worked very well for me so far, since as soon as I have to add features that depend on m_Url, I only have to do this:

connect (this, & MyClass :: urlChanged, & foo, & MyOtherClass :: doBar);

And this is reliable because, basically, foo.com/foo at foo.com/bar will always be a significant change, the perfect signal that informs me when to try the injection of JavaScript code. (Well, it's not really perfect.) Running conditions appear, making complicated and complicated code injection, one of the problems I would like to solve by designing a better API than the one I'm using. have now.)


Now, I must say that HTML and web development were not my original strengths in programming, and as such, I did not understand why these signals would exist:

But, there was no signal for htmlChanged. Instead, all you have is:

Which is a function that will capture the current state. I had to manually call him on a timer whenever I wanted to check for a change of state.

So that's what I did, and then I discovered that even the HTML code of a static web page, or at least the one I was working with, was constantly changing, in which the changes had not changed. no meaning, and that's why none of this signal has been included by Qt's developers.

The heart of the problem

So I know what you are saying, "significant is a subjective and situational term ", so let me define what I mean by significant

It's an excerpt of HTML code, say about 10,000 lines, the change I noticed on a webpage:

change in this

and returns to a constant loop. The fact that it comes back to the original state in a constant loop is what makes this change no Sensand for that matter, it's not something I know how to follow intelligently. My initial strategy of detecting each change in the html string and analyzing it over an interval seems to me to be a very bad approach.

And yet, that being said, I really need signals that will tell me the appearance of buttons or timer, to then inject JavaScript code that push buttons at the right time.

The fundamental questions

  • How I intelligently discover and follow significant changes in HTML? For example, suppose that a single value changes in an HTML document of 100,000 lines; Do I repair the entire document, compare it and find the change, or is there a way to avoid all that and correct the difference?

  • What API design philosophies, or existing APIs, should I use when interfacing with HTML, which will give me the correct signals for code injection or the right time for it? data extraction?

The answer should ideally take into account that the backend is Qt / C ++ oriented so that I can easily interface with the other libraries I depend on. I can do things like inject JQuery into the web page, or follow printfs and others. If that counts, the current engine I'm using is based on Chromium, https://wiki.qt.io/QtWebEngine.

HAProxy as reverse proxy for backend already enabled with SSL and SSL terminator for exposed backend in port 80

I have 4 servers:

  • Proxy server,
  • $ BK_SERVER_001,
  • $ BK_SERVER_002 and
  • $ BK_SERVER_003

The "proxy_server" has only one HAProxy-compatible service with this configuration:
(please look at the lines labeled OPTION 1 and OPTION 2)

# StackOverflow
global
log / dev / log local0
log / dev / log local1 reviews
chroot / var / lib / haproxy
Statistics taking / mode / haproxy / admin.sock mode 660 auditor administrators exposed-fd
waiting time statistics 30s
haproxy user
haproxy group
daemon

# Default SSL material locations
ca-base / etc / ssl / certs
crt-base / etc / ssl / private

ssl-default-bind-ciphers ECDH + AESGCM: DH + AESGCM: ECDH + AES256: DH + AES256: ECDH + AES128: DH + AES: RSA + AESGCM: RSA + AES :! aNULL :! aNULL :! MD5 :! DSS
ssl-default-bind-options no-sslv3

defaults
wait time connect 10s
30s customer waiting time
wait time server 30s
global log
http mode
option httplog
option dontlognull

# ***************** port 80 defs *************
frontend http_in
http mode
option httplog
bind *: 80
forwardfor option

acl host_goose hdr (host) -i www.example.edu
https code redirect scheme 301 if! host_goose
use_backend http_goose if host_goose

backend http_goose
http mode
Server sonar $ BK_SERVER_003: 8080

# ***************** port 443 defs *************
frontend https_in
tcp mode
tcplog option

# With this one everything works except sonar (OPTION 1)
# bind *: 443

# With this one, only sonar works (OPTION 2)
bind *: 443 ssl crt sonar.pem

acl tls req.ssl_hello_type 1
tcp-request inspect-delay 5s
tcp-request content accept if tls

acl host_server001 req.ssl_sni -i opengrok.ci.example.edu
acl host_server002 req.ssl_sni -i gitlab.ci.example.edu
acl host_server003 req.ssl_sni -i jenkins.ci.example.edu
acl host_server004 req.ssl_sni -i nexus.ci.example.edu
acl host_server005 req.ssl_sni -i rancher.ci.example.edu
acl host_server006 req.ssl_sni -i reports.ci.example.edu
acl host_server007 hdr (host) -i sonar.ci.example.edu

use_backend https_server001 if host_server001
use_backend https_server002 if host_server002
use_backend https_server003 if host_server003
use_backend https_server004 if host_server004
use_backend https_server005 if host_server005
use_backend https_server006 if host_server006
use_backend https_server007 if host_server007


#opengrok
backend https_server001
tcp mode
server server001 $ BK_SERVER_001: 28443
#gitlab
backend https_server002
tcp mode
server server002 $ BK_SERVER_002: 10443
#jenkins
backend https_server003
tcp mode
server server003 $ BK_SERVER_001: 7443
#link
backend https_server004
tcp mode
server server004 $ BK_SERVER_001: 8443
#rancher
backend https_server005
tcp mode
$ server server $ BK_SERVER_002: 9443
#reports
backend https_server006
tcp mode
server server006 $ BK_SERVER_001: 4443
#sonar
backend https_server007
http mode
server server007 $ BK_SERVER_001: 9000

For OPTION 2, HAProxy was able to publish the "sonar" service using the given certificate. However, other services try to use this certificate.
Since other services are already SSL enabled in the corresponding systems, I do NOT have their certificates.

If I use OPTION 1, HAProxy successfully publishes all services already ssl-backend with the exception of the "sonar" service, because it requires a certificate that I only have at the level the proxy server.

Is it possible to have all services secured with SSL if (as I said) some of them are already secure but that others will be secured by HAProxy with the only one SSL to which I have access for the service "sonar"? How?

Also note that I do not have ssh access to the $ BK_SERVER_xxx servers and that all DNS points to "proxy_server".

Check the email validation in Django Backend

Since the user can disable JavaScript in the browser, how should I proceed to "recheck" by validating an email in the Django backend (in particular, to avoid logging using Webmail ([GMail, Hotmail etc])? Acknowledging.

Add an Open Graph metabal in the backend

I need to set the og: iamge metatag using the Metatag module.
Since there is no option to edit the names of the metatags or add custom ones, I am not sure that this is possible.

Is it possible to do this without a program / from the backend?

images – Changed HTML img markup by default, but not in the backend of the administrator?

Based on some articles on Stack and the ACF forum, I've created a code to modify the default img HTML markup for the lozad.js lazyload script. It works fine, but also works in the back end of the administrator. I was trying to use if (! is_admin ();) but without effects. How can I solve this problem?

loadHTML ($ the_content);
$ post-> loadHTML (mb_convert_encoding ($ the_content, 'HTML-ENTITIES', 'UTF-8'));
$ imgs = $ post-> getElementsByTagName ('img');
// iterate each img tag
foreach ($ imgs as $ img) {
if ($ img-> hasAttribute (& # 39; data-src & # 39;)) continues;
if ($ img-> parentNode-> tagName == & # 39; noscript & # 39;) continues;
$ clone = $ img-> cloneNode ();
$ src = $ img-> getAttribute (& # 39; src & # 39;);
$ img-> removeAttribute (& # 39; src & # 39;)
$ img-> setAttribute ('data-src', $ src);
$ srcset = $ img-> getAttribute ('srcset & # 39;);
$ img-> removeAttribute (srcset & # 39;)
if (! empty ($ srcset)) {
$ img-> setAttribute ('data-srcset & # 39 ;, $ srcset);
}
$ imgClass = $ img-> getAttribute ('class');
$ img-> setAttribute ('class', $ imgClass. & # 39; lozad & # 39;);
$ no_script = $ post-> createElement (& # 39; noscript & # 39;);
$ no_script-> appendChild ($ clone);
$ img-> parentNode-> insertBefore ($ no_script, $ img);
};
return $ post-> saveHTML ();
}
}
add_filter ('acf_the_content', 'acf_content_image_markup', 15);

acf_content_image_markup function ($ the_content) {
libxml_use_internal_errors (true);
$ post = new DOMDocument ();
// $ post-> loadHTML ($ the_content);
$ post-> loadHTML (mb_convert_encoding ($ the_content, 'HTML-ENTITIES', 'UTF-8'));
$ imgs = $ post-> getElementsByTagName ('img');
// iterate each img tag
foreach ($ imgs as $ img) {
if ($ img-> hasAttribute (& # 39; data-src & # 39;)) continues;
if ($ img-> parentNode-> tagName == & # 39; noscript & # 39;) continues;
$ clone = $ img-> cloneNode ();
$ src = $ img-> getAttribute (& # 39; src & # 39;);
$ img-> removeAttribute (& # 39; src & # 39;)
$ img-> setAttribute ('data-src', $ src);
$ srcset = $ img-> getAttribute ('srcset & # 39;);
$ img-> removeAttribute (srcset & # 39;)
if (! empty ($ srcset)) {
$ img-> setAttribute ('data-srcset & # 39 ;, $ srcset);
}
$ imgClass = $ img-> getAttribute ('class');
$ img-> setAttribute ('class', $ imgClass. & # 39; lozad & # 39;);
$ no_script = $ post-> createElement (& # 39; noscript & # 39;);
$ no_script-> appendChild ($ clone);
$ img-> parentNode-> insertBefore ($ no_script, $ img);
};
return $ post-> saveHTML ();
}
function image_tag_class ($ class, $ id, $ align, $ size) {
returns $ class. & # 39; & # 39 ;; lozad
}
add_filter (& nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nt;)

?>

mysql – Operation of the backend and the database of a multiplayer online gaming site

Battery Exchange Network

The Stack Exchange network includes 175 question-and-answer communities, including Stack Overflow, the largest and most reliable online community on which developers can learn, share knowledge and build their careers.

Visit Stack Exchange

backend – Notification system on an application using Firebase

I need to create an application that manages orders between customers who submit orders and the riders who deliver them. The riders work in teams. So, when a customer submits an order, only active runners in that team should receive a notification.

I chose Firebase as the backend for my application, so I used the cloud storage service, cloud functions, authentication and FCM.

My question is: how should I organize my data to achieve what I already mentioned?

I've already made some options:

  1. I have a collection for teams, where all the active runners in this team are registered. When an order is submitted, I poll all active runners in this team (polled by time), then send a notification to each of them.
  2. I have a message subject where active runners are subscribers, and then I post the notification there.

Option # 1 seems too heavy for me. There are many questions to ask. Option 2 does not need a query at all, but how do I manage runner subscriptions to this one (to be more specific, how active runners of this quarter can they subscribe about)?

Prevent an unauthorized mobile app from calling back REST back-end services

In my scenario, I have an Android mobile app that calls my REST back-end services. I want to prevent another app from calling my REST back-end services.
If I use a certificate and a shared key, as well as obscuring the code of my application, attackers can beautify my source code and reverse engineer.

reactjs – Redux – recovers the initial state of the backend – what is the right way to do it?

I would like to get backend variables (ie, showTutorial) for the initial state in a reducer.

I was thinking of using a simple call in gearbox axios, but I'm not sure that's the best way to do it.

Here's how it's done now:

import {UNSET_TUTORIAL, SET_FILTER_BLOCKS} from "../actions/types";


const initialState = {
showTutorial: true, // <-- instead of this
  filterBlocks: "ALL"
};

export default (state = initialState, action) => {
switch (action.type) {
case UNSET_TUTORIAL:
// <- Some axios call here
return {... state, showTutorial: false};

case SET_FILTER_BLOCKS:
return {... state, filterBlocks: action.payload};
default:
return condition;
}
};

I do not want to use redux-persist, I would like to understand how to do it first.

Google Cloud – Backend malsy and LB does not work

Somehow, I broke a SSL LB running with a minor change and I can not get it working again.

VM instance –
– Unhealthy display and giving a 502 error via the external IP (taking the correct SSL certificate)
– Includes firewall rules separately for ports 443 and 80

KG –
– The front-end server is set for HTTPS traffic with the SSL certificate (issued by Let's Encrypt)
– The main server points to port 443 of the above VM instance via the HTTPS protocol (and a zone).

Firewall –
– In addition to the above VM instance, the firewall rule also exists for LB from IP ranges: 130.211.0.0/22, 35.191.0.0/16 via port 443

What should I do? I have also restarted the virtual machine instance.