Is there any way to hook into the host name used by `git_remote_connect`? - libgit2

Since libssh2 doesn't read the SSH config file I'm trying to implement my own support for aliases like this:
Host github
HostName github.com
and the remote URL uses the host alias like this: git#github:path/to/repo.git.
Is there any way to hook into the host name or URL used by git_remote_connect or the SSH transport so that I can transform github into github.com? I was thinking about adding a new callback but I don't want to reinvent the wheel if there's already a way to do this.

I eventually added a new callback to look up the URL for a remote. It's not in upstream libgit2 but it probably could be if it's useful to anybody else.

Related

openvpn http-proxy-option headers, doing it server-side?

i'm connecting to my vpn via a proxy in order to pass some custom headers.
The way i actually do it it's by putting them in my .ovpn gonfig file, something like this:
http-proxy-option CUSTOM-HEADER Host my.host
http-proxy-option CUSTOM-HEADER User-Agent My-User-Agent
But i would like to config the proxy on the server to handle those, so if i ever need to change anything i wouldn't have to modify every configuration.
My final goal is to handle the headers on the server side of the connection in order to put only the http-proxy parameter in the .ovpn config file.
I've tried to follow a Metahackers' article on how to inject http headers with squid but it didn't work for me.
Do you have any advice or do you have resources you can point me at?
Thanks.

Laravel Dusk: The correct localhost port for APP_URL on a remote server?

I am trying to install Dusk on Laravel at a REMOTE host and at some point I need to change the .env file like this
APP_URL=http://localhost:8000
Another tutorial suggested something like
APP_URL=http://localhost:9515
For a remote host, do I need to put "http://localhost:????" and if I need how do I find the port number? I not do I just leave it as "/"?
By the way, I have tested several options and non have worked so far so but I am not sure what causes it so I am trying to pint point the problem.
Set the APP_URL to the same URL you are using in the browser for your local development environment. This can be http://localhost but also a custom URL:
APP_URL=http://dusk.local
For Laravel Homestead you can manage your sites within your Homestead.yaml file.
The APP_URL is somehow important as commands from the terminal require this information as pointed out in detail in this answer.
The port 9515 is the default port number of the Selenium server URL as provided in DuskTestCase.php. There's no need to change it at the beginning as it should work out of the box.
By default, the ports are forwarded to your Homestead environment.

use other command instead of ssh for ansible

I have an ansible configuration which I know works on my local machines. However, I'm trying to now set it up on my company's machines which use a wrapper command similar to ssh (let's call it 'myssh')
for example, to access these machines, instead of writing
ssh myuser#123.123.123.123
you write
myssh myuser#123.123.123.123
which ends up calling ssh, among other things.
My question is, is there a way to swap which command ansible uses for accessing machines?
You can create a Connection Type Plugin to archive this. Looking at the ssh plugin, it appears like it might be as easy as replacing the ssh_cmd in line 333. Also specify myssh in line 69.
See here where to place the modified file. Additionally to that information, you can specify a custom location and let Ansible know about it in connection_plugins setting in ansible.cfg.
Finally again in your ansible.cfg set the transport setting to your new plugin:
transport = myssh
PS: I have never done anything like that before. This is only info from the docs.

Unable to bind phpseclib to specific source IP

It looks like the SSH / SCP code for phpseclib does not support binding to a source IP. Unfortunately, this breaks our use case.
Is there a way to add this support?
phpseclib uses fsockopen to do SSH, which doesn't support binding. You could probably rewrite it to do socket_create / socket_bind. I guess I could do it if you paypal me some money!

Pushing my Mercurial Repository through HTTP with Apache and Windows

So I have managed it. I can clone mercurial-repositories remotely using HTTP to my Windows Server 2003 machine and the ipaddress from that machine. Although I did deactivate IIS6 and am using Apache 2.2.x now. But not all works right now...darn! Here's the thing:
Cloning goes smooth! But when I want to push my changes to the original repository I get the message "cannot lock static http-repository". On the internet I get to read several explanations that Mercurial wasn't designed to push over HTTP connections. Still, on the Mercurial website there's something about configuring an hgrc file.
There's also the possibilty to configure Apache to host via HTTPS (or SSL). For this you have to load the module enabling OpenSSL and generating keys.
Configuring the hgrc file
Just add "push_ssl = false" under the [web] line. But where to put this file when pushing your changes back?! Because I placed it in the root of the server, in the ".hg" directory, nothing works.
Using SSL/HTTPS with Apache
When I try to access 'https://myipaddress' it fails, displaying a dutch message which would mean something like "server taking too long to respond". Trying to push also gives me a dutch error message which means about the same. It can not connect to my server via https although I followed the steps exactly at this blog.
I don't care which of the above solutions will work for me. Turns out none of them work so far. So please, can anyone help me with one of the solutions above? Pick the easiest! Help will be greatly appreciated, not only from me.
Summary
-Windows Server 2003
-Apache 2.2 with OpenSSL
-Mercurial 1.8.2
-I can clone, but not push!
Thank you!
Maarten Baar(s)
It seems like you might have apache configured incorrectly for getting it to do what you want. Based on your question it sounds like you have a path (maybe the root of the server) pointing to the repository you want to serve.
Mercurial comes with a script for this exact purpose, in the latest version it is hgweb.cgi. There are reasonably good instructions for setting it up on the mercurial site. It should allow both cloning and pushing. You will need the push_ssl=false if you will not be configuring https and also an allow_push line which will let certain users, or all (*) push to the repository. But all that should be part of the setup docs.