Trying to create a simple xinetd style server without needing to create a full service first. I have the following file which is located at /etc/xinetd.d/myscript:
service tester
{
disable = no
socket_type = stream
protocol = tcp
port = 8087
wait = no
user = root
server = /root/prog
}
but I keep getting the following error when restarting xinetd:
service/protocol combination not in /etc/services
The solution is to add type = UNLISTED as seen below, and as discussed at https://www.redhat.com/archives/fedora-legacy-list/2004-October/msg00146.html
service tester
{
disable = no
socket_type = stream
protocol = tcp
port = 8087
wait = no
user = root
server = /root/prog
type = UNLISTED
}
Related
I'm having a Local VPN app that using "NETunnelProvider / NetworkExtentsion", In my solution, I created a split tunnel on the device itself to track the DNS request, using NEKit I was able to peek inside the packets and filter the ongoing request based on the destination address (let's call ita UDP listener for DNS requests).
This solution was working fine on iOS 13.7 and less, recently apple release iOS 14, and my solution stop working, VPN connection still established but the user can't access any webSite, I debugged the code and found out the networkExtision does not receive any packets from user activity only.
I'm using the CocoaAsyncSocket library.
func udpSocket(_ sock: GCDAsyncUdpSocket, didReceive data: Data, fromAddress address: Data, withFilterContext filterContext: Any?) {
let host = GCDAsyncUdpSocket.host(fromAddress: address)
guard let message = DNSMessage(payload: data) else {
return
}
guard let session = pendingSession.removeValue(forKey: message.transactionID) else {
return
}
session.realResponseMessage = message
session.realIP = message.resolvedIPv4Address
let domain = session.requestMessage.queries[0].name
let udpParser = UDPProtocolParser()
udpParser.sourcePort = Port(port: dnsServerPort)
udpParser.destinationPort = (session.requestIPPacket!.protocolParser as! UDPProtocolParser).sourcePort
udpParser.payload = session.realResponseMessage!.payload
let ipPacket = IPPacket()
ipPacket.sourceAddress = IPAddress(fromString: dnsServerAddress)
ipPacket.destinationAddress = session.requestIPPacket!.sourceAddress
ipPacket.protocolParser = udpParser
ipPacket.transportProtocol = .udp
ipPacket.buildPacket()
packetFlow.writePackets([ipPacket.packetData], withProtocols: [NSNumber(value: AF_INET as Int32)])
}
let dummyTunnelAddress = "127.0.0.1"
let dnsServerAddress = "8.8.4.4"
let dnsServerPort: UInt16 = 53
// Tunnel confg.
let tunnelAddress = "192.168.0.1"
let tunnelSubnetMask = "255.255.255.0"
Regarding triggering"Local Network permissions" which is not the issue here (I don't think my solution need to have this permission), Based on the apple document some apps need to request local network permissions, I added the permission to the info.plist but local network permissions are not triggered.
==========================
Update #1
============================
I found out that I was able to capture the packets and do my own things then write packets back to the packetFlow packetFlow.writePackets, But on iOS 14 browsers not loading the websites and keep loading until show time out.
I have an idea, and maybe a solution for you. Starting in iOS version 14, the C function connect() started failing in network extensions, where VPNs have to run, with the following log message from the kernel:
Sandbox: VPN Extensio(8335) deny(1) network-outbound*:<port #>
However, it does work in the app, which is next to useless if you need it in the extension. GCDAsyncUdpSocket is a thin layer that right under the covers is calling socket() and connect().
NWConnection does work in a network extension, and it should work for you if it is feasible to port your code and you don't need the actual socket descriptor. But you will have to conditionally compile if you have to support devices < ios 12.
I have several remote nodes that stay on different computers and connected in cluster.
So, it is logging system on one of the nodes with role 'logging', that write logs in db.
I chose to use routing for delivering messages to logger from other nodes.
I have one node with main actor and three child actors. Each of them must send logs to logger node.
My configuration for router:
akka.actor.deployment {
/main/loggingRouter = {
router = adaptive-group
nr-of-instances = 100
cluster {
enabled = on
routees-path = "/user/loggingEvent"
use-role = logging
allow-local-routees = on
}
}
"/main/*/loggingRouter" = {
router = adaptive-group
nr-of-instances = 100
cluster {
enabled = on
routees-path = "/user/loggingEvent"
use-role = logging
allow-local-routees = on
}
}
}
And I create router in each actor with this code
val logging = context.actorOf(FromConfig.props(), name = "loggingRouter")
And send
logging ! LogProtocol("msg")
After that logger receives messages only from one child actor. I don't know how to debug it, but my guess that I apply wrong pattern for this.
What is the best practice for this task? Thx.
Actor from logger node:
system.actorOf(Logging.props(), name = "loggingEvent")
Problems is in routers with the same names. Ass I see, good pattern is to create one router in main actor and send it to children.
I have a Java EE app that runs in Tomcat, uses Tomcat connection pooling, over postgres database, and the application uses OpenJPA for ORM.
For some operations, I need to get access to LargeObjectManager API from postgres. That requires me having a reference to the actual postgres connection object.
So, I'm trying to drill into the connection object I get from OpenJPA, to get the actual Postgres one. But I'm stopped by a 'sun.misc.proxy.$ProxyNN' object, and I'm not sure how can I get further.
Here is what I'm doing now:
OpenJPAEntityManager oem = OpenJPAPersistence.cast(em);
// get open JPA connection object
Connection c = oem.getConnection();
// all the way down to what's no longer OpenJPA
c = ((DelegatingConnection)c).getInnermostDelegate()
And that's where I stop. The returned object is below. I can't call ProxyConnection methods on it, and I don't even know who creates these proxies (but I bet it's Tomcat DBCP).
c = {com.sun.proxy.$Proxy5#1793}"ProxyConnection[PooledConnection[Pooled connection wrapping physical connection org.postgresql.jdbc4.Jdbc4Connection#a7a434]]"
h = {org.apache.tomcat.jdbc.pool.ProxyConnection#5671}"ProxyConnection[PooledConnection[Pooled connection wrapping physical connection org.postgresql.jdbc4.Jdbc4Connection#a7a434]]"
connection = {org.apache.tomcat.jdbc.pool.PooledConnection#5673}"PooledConnection[Pooled connection wrapping physical connection org.postgresql.jdbc4.Jdbc4Connection#a7a434]"
poolProperties = {org.apache.tomcat.jdbc.pool.PoolProperties#5676}"ConnectionPool[defaultAutoCommit=false; defaultReadOnly=null; defaultTransactionIsolation=-1; defaultCatalog=null; driverClassName=null; maxActive=100; maxIdle=100; minIdle=10; initialSize=10; maxWait=30000; testOnBorrow=false; testOnReturn=false; timeBe...
connection = {com.sun.proxy.$Proxy0#5677}"Pooled connection wrapping physical connection org.postgresql.jdbc4.Jdbc4Connection#a7a434"
h = {org.postgresql.ds.jdbc23.AbstractJdbc23PooledConnection$ConnectionHandler#5686}
xaConnection = null
abandonTrace = null
timestamp = 1372621172141
lock = {java.util.concurrent.locks.ReentrantReadWriteLock#5678}"java.util.concurrent.locks.ReentrantReadWriteLock#9267fe[Write locks = 0, Read locks = 0]"
discarded = false
lastConnected = 1372620679402
lastValidated = 1372620679398
parent = {org.apache.tomcat.jdbc.pool.ConnectionPool#5674}
attributes = {java.util.HashMap#5679} size = 2
handler = {org.apache.tomcat.jdbc.pool.ProxyConnection#5671}"ProxyConnection[PooledConnection[Pooled connection wrapping physical connection org.postgresql.jdbc4.Jdbc4Connection#a7a434]]"
released = {java.util.concurrent.atomic.AtomicBoolean#5680}"false"
suspect = false
driver = null
pool = {org.apache.tomcat.jdbc.pool.ConnectionPool#5674}
properties = null
next = null
useEquals = true
tomcat: 7.0.22
postgres jdbc:9.2-1002
openJPA: 2.1.1
Give this a try, might require some tweaking but I believe it should work as is or at least give you some useful pointers of where are the proxies that need to be unwrapped
//unwrap proxy invocation handler
org.apache.tomcat.jdbc.pool.ProxyConnection tomcatProxy = (ProxyConnection) Proxy.getInvocationHandler(c);
org.apache.tomcat.jdbc.pool.PooledConnection tomcatPooledConnection = tomcatProxy.getConnection(); //if this doesn't work try getDelegateConnection!
Connection connection = tomcatPooledConnection.getConnection();
then try
org.postgresql.jdbc4.Jdbc4Connection jdbc4conn = (org.postgresql.jdbc4.Jdbc4Connection) connection;
jdbc4conn.getLargeObjectAPI();
if the above cast fails try:
org.postgresql.ds.jdbc23.AbstractJdbc23PooledConnection psAbstractPooledConn = Proxy.getInvocationHandler(connection.getProxy().getConnection());
Well, if it does not work, if you can give more info on these other objects and their attributes it will be really helpful, but the idea here is to get the invocation handlers generated using JDK Proxies and the connection from Tomcat proxies
From c# code I call schtasks to delete some scheduled tasks. I make the first call and I get this error returned:
ERROR: Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed....
Here's the code that runs the process:
Process stProc = new Process();
stProc.StartInfo.UseShellExecute = false;
stProc.StartInfo.FileName = "SCHTASKS.exe";
stProc.StartInfo.RedirectStandardError = true;
stProc.StartInfo.RedirectStandardOutput = true;
stProc.StartInfo.CreateNoWindow = true;
stProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
stProc.StartInfo.Arguments = args;
stProc.Start();
stProc.BeginOutputReadLine();
stProc.BeginErrorReadLine();
stProc.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
stProc.ErrorDataReceived += new DataReceivedEventHandler(p_ErrorDataReceived);
stProc.WaitForExit();
stProc.Close();
stProc.Dispose();
My arguments are correct as per: http://msdn.microsoft.com/en-us/library/bb736357(v=vs.85).aspx
Just to make sure that my connection is not hanging around, I create a new process to kill it before every delete call:
StartProcess(args);
Process x = new Process();
x.StartInfo.FileName = "cmd";
x.StartInfo.Arguments = #" net use \\servername\ipc$ /delete";
x.StartInfo.CreateNoWindow = true;
x.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
x.Start();
Not sure what's up here. Might it be someone else that's using this machine and so my calls can't get through?
Any ideas appreciated!
Thanks!!
The answer is this: http://support.microsoft.com/kb/938120
I used the IP address of the machine.
One way of creating JmDNS services is :
ServiceInfo.create(type, name, port, weight, priority, props);
where props is a Map which describes some propeties of the service. Does anybody have an example illustrating the use of theese properties, for instance how to use them in the reciever part.
I've tried :
Hashtable<String,String> settings = new Hashtable<String,String>();
settings.put("host", "hhgh");
settings.put("web_port", "hdhr");
settings.put("secure_web_port", "dfhdyhdh");
ServiceInfo info = ServiceInfo.create("_workstation._tcp.local.", "service6", 80, 0, 0, true, settings);
but, then in a machine receiving this service, what can I do to see those properties?
I would apreciate any help...
ServiceInfo info = jmDNS.getServiceInfo(serviceEvent.getType(), serviceEvent.getName());
Enumeration<String> ps = info.getPropertyNames();
while (ps.hasMoreElements()) {
String key = ps.nextElement();
String value = info.getPropertyString(key);
System.out.println(key + " " + value);
}
It has been a while since this was asked but I had the same question. One problem with the original question is that the host and ports should not be put into the text field, and in this case there should actually be two service types one secure and one insecure (or perhaps make use of subtypes).
Here is an incomplete example that gets a list of running workstation services:
ServiceInfo[] serviceInfoList = jmdns.list("_workstation._tcp.local.");
if(serviceInfoList != null) {
for (int index = 0; index < serviceInfoList.length; index++) {
int port = serviceInfoList[index].getPort();
int priority = serviceInfoList[index].getPriority();
int weight = serviceInfoList[index].getWeight();
InetAddress address = serviceInfoList[index].getInetAddresses()[0];
String someProperty = serviceInfoList[index].getPropertyString("someproperty");
// Build a UI or use some logic to decide if this service provider is the
// one you want to use based on prority, properties, etc.
...
}
}
Due to the way that JmDNS is implemented the first call to list() on a given type is slow (several seconds) but subsequent calls will be pretty fast. Providers of services can change the properties by calling info.setText(settings) and the changes will be propagated out to the listeners automatically.