Javascript – Flask SocketIO does not connect properly to respond to client

I'm trying to connect my React client to a SocketIO connection like this one.

socket = SocketIO(app, cors_allowed_origins="*")

@socket.on('test')
def test(data):
    print("test")
    print(data)

and connection on the client side

 //wrapped in a async function

const socket = openSocket('http://localhost:5000');

export const sendMessage = (user, content, attachments) =>{
    const data = {
        sender: user,
        content: content, 
        attachments: attachments,
        timeStamp: Date.now()
    }
    try{
        const res = socket.emit('test', data)
        return stringify(res)
    }catch(exception){
        return exception
    }

}

On the server side I get a response of 200, as if the connection is set up correctly, but on the client side I get this error

886313e1-3b8a-5372-9b90-0c9aee199e5d:1 Access to 
XMLHttpRequest at 'http://localhost:5000/socket.io/?EIO=3&transport=polling&t=MvQD3QE' from origin 'http://localhost:3000' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

If I remove that cors_allowed_origins="*" I get a 400 on the server side, but I always get the error on the client side.

Windows – How to show OpenVPN client on a specific gateway?

I have a Windows computer connected to LAN and Wi-Fi. Each is located in two different private networks. One is 192.x.x.x and the other is 172.x.x.x.

I'm trying to configure the OpenVPN client to connect over the LAN interface, which is located on the 192.x.x.x network. The VPN connection connects to an external VPN server over the 192.x.x.x network. Then I would use SSH over the VPN to access the server on the network where the VPN server resides.

So, I want to use ssh to connect to the server behind the VPN, but I can still use other applications / browsing the Internet over the 172.x.x.x network.

What I see is the routing table and it is configured that there are two default routes that use the 172.xxx and 192.xxx gateways, but the network metric for the 172.xxx network is set to a lower one, so the openVPN client the 172.xxx uses network, that's not the goal.

What I do now:

I reduce the metric of network 192.x.x.x in the routing table to be lower than the metric 172.x.x.x. Then I connect to the VPN server and change the metrics back so that all other traffic is routed over the 172.x.x.x network, but I can still use SSH over the created VPN tunnel.

I am open to ideas and possible workarounds.

Multiplayer – communication between client and separate host Unity Unet

I'll create a real-time multiplayer game like a little quiz game that players can take part in and then the quiz master who manages the host will start the game. I need to know how to do this functionality. This is my server script.

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Networking.Types;
using UnityEngine.Networking.Match;
public class Server : MonoBehaviour
{
    #region Variables

    //CONSTANTS
    private const int MAX_CONECTIONS = 40;
    private const string SERVER_IP = "127.0.0.1";
    private const int SERVER_PORT = 8999;
    private const int SERVER_WEB_PORT = 8998;
    private const int BUFFER_SIZE = 1024;
    private const int BYTE_SIZE = 1024;

    //CHANNELS
    private int reliableChannelID;
    private int unReliableChannelID;

    //HOSTS
    private int hostID;
    private int webHostID;


    //LOGIC
    private bool isInit;
    private byte() buffer = new byte(BUFFER_SIZE);

    private byte error;

    //GAME FUNCTION
    public bool gameStarted;
    public bool isStarted;
    private float startTime = 10f;
    private float timer;

    List matchList = new List();
    bool matchCreated;
    NetworkMatch networkMatch;

    #endregion

    //CLASS REFERENCES
    ButtonScript gameStartObject = new ButtonScript();
    CountDown countDown = new CountDown();

    string timerCountDown;

    //HOSTING FUNCTION REFERENCE
    private string monthName;
    private string roomname;

    void Awake()
    {
        networkMatch = gameObject.AddComponent();
    }

    private void Start()
    {
        monthName = (DateTime.Now.Month).ToString("MMM");
        roomname = ("HNB Quiz Mania - " + monthName);
        Debug.Log(roomname);
        GlobalConfig confing = new GlobalConfig();
        NetworkTransport.Init(confing);

        //HOST TOPOLOGY
        ConnectionConfig connectionConfig = new ConnectionConfig();
        reliableChannelID = connectionConfig.AddChannel(QosType.Reliable);
        unReliableChannelID = connectionConfig.AddChannel(QosType.Unreliable);
        HostTopology topology = new HostTopology(connectionConfig, MAX_CONECTIONS);

        //ADDING HOSTS
        hostID = NetworkTransport.AddHost(topology, SERVER_PORT); // when adding the connection in actual server, -> hostID/webHostID = NetworkTransport.AddHost(topology, SERVER_PORT/SERVER_WEB_PORT,BINDINGHOSTIP);
        webHostID = NetworkTransport.AddWebsocketHost(topology, SERVER_WEB_PORT);

        isInit = true;
        Debug.Log("Starting the serer");

        //SETTING TIMER TO QUESTION RESERVED TIME
        timerCountDown = countDown.timeLeft.ToString("F2");
        gameStarted = gameStartObject.isStartGameCliked;
    }

    // Update is called once per frame
    private void Update()
    {
        if (!isInit) { return; }

        #region Local Variables
        int outHostId;
        int outConnectionId;
        int outChannelId;

        int receivedSize;
        byte error;
        byte() buffer = new byte(256);
        #endregion

        NetworkEventType evt = NetworkTransport.Receive(out outHostId, out outConnectionId, out outChannelId, buffer, buffer.Length, out receivedSize, out error);

        if (evt == NetworkEventType.Nothing) { return; } //If there is no event, terminate the process

        #region UpdateMessagePump

        switch (evt)
        {
            case NetworkEventType.ConnectEvent:
                {
                    Debug.Log("Conntection from : " + outConnectionId + " through the channel : " + outChannelId);
                    Debug.Log(string.Format("User {0} has connected", outConnectionId));
                    break;
                }//When somebody connected and still dont have a connection ID and all the other information to be connected to a server, hard to have the full context around the user untill they connects. 
            case NetworkEventType.DisconnectEvent:
                {
                    Debug.Log("Disconntection from : " + outConnectionId + " through the channel : " + outChannelId);
                    Debug.Log(string.Format("User {0} has disconnected", outConnectionId));
                    break;
                }   //
            case NetworkEventType.DataEvent:
                {
                    Debug.Log("Data from : " + outConnectionId + " through the channel : " + outChannelId + "::Message::" + buffer);
                    DataEvent(buffer);
                    break;
                }
            case NetworkEventType.BroadcastEvent:
                {
                    Debug.Log("Unexpected Nettwork event type" + evt);
                    break;
                }
            case NetworkEventType.Nothing:
                {
                    return;
                }

            default:

                Debug.Log("Unknown Nettwork message type recieved : " + evt);
                break;
        } 

        #endregion

        if (gameStarted)
        {
            Debug.Log("Calling timer");
            StartGameQuiz(gameStarted);
        }
        else
        {
            Debug.Log("...Game hasn't started yet...");
        }

        Debug.Log("client countdown : " + timerCountDown);
        Debug.Log("client countdown test 2: " + countDown.timeLeft.ToString("F2"));



    }

    public void UpdatemessagePump()
    {
        if (!isStarted) { return; }

        int recHostID;      //Which platform
        int connectionID;   //Which User Sending the message
        int channelID;      //Which Lane used to send the specific message

        byte() recBuffer = new byte(BYTE_SIZE);
        int dataSize;

        NetworkEventType type = NetworkTransport.Receive(out recHostID, out connectionID, out channelID, recBuffer, BYTE_SIZE, out dataSize, out error);

        switch (type)
        {
            case NetworkEventType.Nothing:
                {
                    break;
                }
            case NetworkEventType.ConnectEvent:
                {
                    Debug.Log(string.Format("User {0} has connected",connectionID));
                    break;
                }
            case NetworkEventType.DisconnectEvent:
                {
                    Debug.Log(string.Format("User {0} has disconnected", connectionID));
                    break;
                }   //
            case NetworkEventType.DataEvent:
                {
                    BinaryFormatter formatter = new BinaryFormatter();
                    MemoryStream memoryStream = new MemoryStream(recBuffer);
                    NetMessage message = (NetMessage)formatter.Deserialize(memoryStream);

                    OnData(connectionID, channelID, recHostID, message);
                    break;
                }

            default:
            case NetworkEventType.BroadcastEvent:
                Debug.Log("Unexpected Nettwork event type" + type);
                break;
        }
    }

    void DataEvent(byte() dataBuffer)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        MemoryStream memoryStream = new MemoryStream(dataBuffer);
        NetMessage message = (NetMessage)formatter.Deserialize(memoryStream);
    }


    #region OnData
    private void OnData(int connectionID, int channelID, int recHostID, NetMessage message)
    {
        switch (message.OperationCode)
        {
            case NetOperationCode.none:
                Debug.Log("Unexpected Network Operation");
                break;

            case NetOperationCode.createAccount:
                CreateAccount(connectionID, channelID, recHostID, (Net_CreateAccount)message);
                break;
        }
    }

    private void CreateAccount(int connectionID, int channelID, int recHostID, Net_CreateAccount createAccountMessage)
    {
        Debug.Log("create account message");
        Debug.Log(string.Format("{0},{1},{2}", createAccountMessage.username, createAccountMessage.password, createAccountMessage.sessionID));
    }

    #endregion

    public void StartGameQuiz(bool gameStared)
    {
            Debug.Log("Quiz begun");

    }

    #region SendingData
    public void SendClient(int recHostID, int connectionID, NetMessage message)
    {
        //data hodler
        byte() dataBuffer = new byte(BYTE_SIZE);

        //crushing data to byte array
        BinaryFormatter formatter = new BinaryFormatter();
        MemoryStream memoryStream = new MemoryStream(dataBuffer);
        formatter.Serialize(memoryStream, message);

        if(recHostID == 0)
        {
            NetworkTransport.Send(hostID, connectionID, reliableChannelID, dataBuffer, BYTE_SIZE, out error);
        }

        else
        {
            NetworkTransport.Send(webHostID, connectionID, reliableChannelID, dataBuffer, BYTE_SIZE, out error);
        }

    }


    #endregion

}

And that's my client script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

public class Client : MonoBehaviour
{
    #region Variables

    //CONSTANTS
    private const int MAX_CONECTIONS = 40;
    private const string SERVER_IP = "127.0.0.1";
    private const int SERVER_PORT = 8999;
    private const int SERVER_WEB_PORT = 8998;
    private const int BUFFER_SIZE = 1024;

    private const int BYTE_SIZE = 1024;

    //CHANNELS
    private int reliableChannelID;
    private int unReliableChannelID;

    //HOSTS
    private int hostID;
    private int connectionID;


    //LOGIC
    private bool isConnected;
    private byte() buffer = new byte(BUFFER_SIZE);

    private byte error;
    #endregion
    private bool isStarted;
    // Start is called before the first frame update
    private void Start()
    {
        //getting the msg that server is started or not
        ButtonScript gameObject = new ButtonScript();

        GlobalConfig confing = new GlobalConfig();
        NetworkTransport.Init(confing);

        //HOST TOPOLOGY
        ConnectionConfig connectionConfig = new ConnectionConfig();
        reliableChannelID = connectionConfig.AddChannel(QosType.Reliable);
        unReliableChannelID = connectionConfig.AddChannel(QosType.Unreliable);
        HostTopology topology = new HostTopology(connectionConfig, MAX_CONECTIONS);

        //CONNECTING TO HOSTS
        hostID = NetworkTransport.AddHost(topology, 0); //DEFINE WHAT CONNECTION TO BE SYNC WITH AND TO CARRY TOPOLOGY IN SAME NETWORK MAP

        //Standalone client
#if UNITY_WEBGL
    //WEBGL client
    connectionID = NetworkTransport.Connect(hostID, SERVER_IP, SERVER_WEB_PORT, 0, out error);
#else
        //Standalone client

        connectionID = NetworkTransport.Connect(hostID, SERVER_IP, SERVER_PORT, 0, out error);
#endif

        isStarted = gameObject.isStartGameCliked;

        if (isStarted)
        {
            Debug.Log("Server is online and Game is now starting");
        }
    }

    private void Update()
    {
        UpdatemessagePump();
    }

    public void UpdatemessagePump()
    {
        if (!isStarted) { return; }

        int recHostID;      //Which platform
        int connectionID;   //Which User Sending the message
        int channelID;      //Which Lane used to send the specific message

        byte() recBuffer = new byte(BYTE_SIZE);
        int dataSize;

        NetworkEventType type = NetworkTransport.Receive(out recHostID, out connectionID, out channelID, recBuffer, BYTE_SIZE, out dataSize, out error);

        switch (type)
        {
            case NetworkEventType.Nothing:
                {
                    break;
                }
            case NetworkEventType.ConnectEvent:
                {
                    Debug.Log(string.Format(" connected to the server", connectionID));
                    break;
                }
            case NetworkEventType.DisconnectEvent:
                {
                    Debug.Log(string.Format("disconnected from the server", connectionID));
                    break;
                }   //
            case NetworkEventType.DataEvent:
                {
                    BinaryFormatter formatter = new BinaryFormatter();
                    MemoryStream memoryStream = new MemoryStream(recBuffer);
                    NetMessage message = (NetMessage)formatter.Deserialize(memoryStream);

                    OnData(connectionID, channelID, recHostID, message);

                    break;
                }

            default:
            case NetworkEventType.BroadcastEvent:
                Debug.Log("Unexpected Nettwork event type" + type);
                break;
        }
    }

    #region OnData
    private void OnData(int connectionID, int channelID, int recHostID, NetMessage message)
    {
        switch (message.OperationCode)
        {
            case NetOperationCode.none:
                Debug.Log("Unexpected Network Operation");
                break;

        }

    }

    #endregion

    #region SendingData
    public void SendServer(NetMessage message)
    {
        //data hodler
        byte() dataBuffer = new byte(BYTE_SIZE);

        //crushing data to byte array
        BinaryFormatter formatter = new BinaryFormatter();
        MemoryStream memoryStream = new MemoryStream(dataBuffer);
        formatter.Serialize(memoryStream, message);

        NetworkTransport.Send(hostID, connectionID, reliableChannelID, dataBuffer, BYTE_SIZE, out error);
    } 
    #endregion

    public void TESTFUNCTIONCREATEACCOUNT()
    {
        Net_CreateAccount createAccount = new Net_CreateAccount();
        createAccount.username = "Sakuna";
        createAccount.password = "test1234";
        createAccount.sessionID = "quiz+week+1+0";

        SendServer(createAccount);

    }
}

This script displays the message that a connection to the server has been established. What I need to know is that when the host starts the game, each client can start at the same time.

Would someone please help …? All the advice will be very helpful.
My unit version is 2019.2

tls – how can I use Python requests SSL with Chrome client certificate

I am writing a splider for nike.com
but this website ssl needs to verify ssl fingerprint

I download the client certificate from Chrome and use it

openssl x509 -inform der -in nike.cer -out nike_certificate.pem

requests.post(cert=nike_certificate.pem)

Exception:

(Caused by SSLError(SSLError(336265225, '(SSL) PEM lib (_ssl.c:3845)')))

Websocket client for Unity

So is there an implementation for Websockets in Unity that actually works?
There are many good WebsocketApis for C #, but not for Unity.

For security reasons, JavaScript code does not have direct access to IP sockets to implement network connectivity. As a result, the .NET network
Classes (that is, everything in the System.Net namespace, especially System.Net.Sockets) are not functional in WebGL

And yes, there could be a double question, but none of the others is also answered ^^

thank you in advance

Access the SharePoint site list through the Angular client

When I go to the Microsoft Graph Explorer and use a URL like:

https://graph.microsoft.com/beta/sites/4development106.sharepoint.com:/sites/DBSchenker:/lists/OEC_Docs/items

I can see that my request was successful.

Well, if I use the Angular app from GitHub and like the code

 private sharePointHost: string = "https://4development106.sharepoint.com/sites/DBSchenker/_api/web/lists/getByTitle('OEC_Docs')/items"

  getDocuments(token){
    const httpOptions = {
      headers: new HttpHeaders({
          'Accept':  'application/json;odata=verbose'
          ,'Authorization' : "Bearer " + token
        })
      };

    this.http.get(this.sharePointHost, httpOptions).subscribe(
      (resp) => console.log("respon is::: " + JSON.stringify(resp)),
      (err) => console.log("error:::" + JSON.stringify(err))
    )
  }

It raises:

error:::{"headers":{"normalizedNames":{},"lazyUpdate":null},"status":401,"statusText":"OK","url":"https://4development106.sharepoint.com/sites/DBSchenker/_api/web/lists/getByTitle('OEC_Docs')/items","ok":false,"name":"HttpErrorResponse","message":"Http failure response for https://4development106.sharepoint.com/sites/DBSchenker/_api/web/lists/getByTitle('OEC_Docs')/items: 401 OK","error":{"error_description":"Invalid JWT token. No certificate thumbprint specified in token header."}}

Change host in (works in Graph API Explorer)

private sharePointHost: string = "https://graph.microsoft.com/beta/sites/4development106.sharepoint.com:/sites/DBSchenker:/lists/OEC_Docs/items"

raises

error:::{"headers":{"normalizedNames":{},"lazyUpdate":null},"status":401,"statusText":"Unauthorized","url":"https://graph.microsoft.com/beta/sites/4development106.sharepoint.com:/sites/DBSchenker:/lists/OEC_Docs/items","ok":false,"name":"HttpErrorResponse","message":"Http failure response for https://graph.microsoft.com/beta/sites/4development106.sharepoint.com:/sites/DBSchenker:/lists/OEC_Docs/items: 401 Unauthorized","error":{"error":{"code":"InvalidAuthenticationToken","message":"Access token validation failure.","innerError":{"request-id":"f5a77afc-0d92-49a0-92c4-e727e056d0a9","date":"2018-10-30T01:42:02"}}}}

I'm not sure what I'm doing wrong

Postfix mail server: smtpUseSSL = true on the mail client ignores SASL authentication

Configured Postfix server with SSL authentication enabled. Could configure the mail client and send emails through the server if user / passport is correct and emails are not sent if user / passport is wrong. So verify that sasl auth works.

Also uses Telnet to verify the SSL authentication of the mail server.

Telnet 25

However, if the client is set to smtpUseSSL = true, emails will also be sent via the server with the wrong user / pass.

Please help me diagnose the problem with the server.

Below you will find the content of main.cf:

ueue_directory = / var / spool / postfix
command_directory = / usr / sbin
daemon_directory = / usr / libexec / postfix
Data directory = / var / lib / postfix
mail_owner = postfix

myhostname =

mydomain =

myorigin = $ myhostname

inet_interfaces = all

inet_protocols = all

mydestination = $ myhostname, localhost. $ mydomain, localhost

unknown_local_recipient_reject_code = 550

mynetworks_style = subnet

alias_maps = hash: / etc / alias
alias_database = hash: / etc / aliases

mail_spool_directory = / var / mail

debug_peer_level = 2
debugger_command =
PATH = / bin: / usr / bin: / usr / local / bin: / usr / X11R6 / bin
ddd $ daemon_directory / $ process_name $ process_id & sleep 5

smtpd_sasl_path = smtpd

smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes

smtpd_sasl_security_options = noanonymous

smtpd_recipient_restrictions =
allow_mynetworks
permit_sasl_authenticated
reject_unauth_destination

smtp_sasl_password_maps = hash: / etc / postfix / sasl_passwd

header_checks = pcre: / etc / postfix / header_checks

sharepoint online – Vendor hosted apps – client ID and client secret

If you generate a client ID / secret, you must specify the domain in which the app resides. You can only specify a single domain. When you generate the ID / secret, the service principal is created on the Azure tenant, using the client ID and client ID / domain as SPNs.

For example with an ID of 123e4567-e89b-12d3-a456-426655440000and a domain of contoso.comare the following service principal names:

123e4567-e89b-12d3-a456-426655440000
123e4567-e89b-12d3-a456-426655440000/contoso.com

These must be unique for all service principals, meaning you can not have two apps with the same client ID.

However, you can have any ID / secret used by an app. However, if the domain does not match the domain for which the ID is registered, users will receive a warning when they navigate to the app (though they can go through it).

If you're interested, here's an answer for generating IDs / secrets about PowerShell. I also have some scripts for retrieving / updating secrets.