diff --git a/repository/Zinc-HTTP-UnixSocket.package/.filetree b/repository/Zinc-HTTP-UnixSocket.package/.filetree new file mode 100644 index 00000000..57a67973 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/.filetree @@ -0,0 +1,5 @@ +{ + "separateMethodMetaAndSource" : false, + "noMethodMetaData" : true, + "useCypressPropertiesFile" : true +} \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/Socket.extension/class/newIPC.st b/repository/Zinc-HTTP-UnixSocket.package/Socket.extension/class/newIPC.st new file mode 100644 index 00000000..889906b2 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/Socket.extension/class/newIPC.st @@ -0,0 +1,7 @@ +*Zinc-HTTP-UnixSocket +newIPC + "Create a socket and initialise it for IPC aka Unix domain." + + self initializeNetwork. + ^ [ super new initialize: TCPSocketType withDomain: 1 ] + repeatWithGCIf: [ :socket | socket isValid not ] \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/Socket.extension/instance/initialize.withDomain..st b/repository/Zinc-HTTP-UnixSocket.package/Socket.extension/instance/initialize.withDomain..st new file mode 100644 index 00000000..d8b064c5 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/Socket.extension/instance/initialize.withDomain..st @@ -0,0 +1,28 @@ +*Zinc-HTTP-UnixSocket +initialize: socketType withDomain: socketDomain + "Initialize a new socket handle. If socket creation fails, socketHandle will be set to nil." + + | semaIndex readSemaIndex writeSemaIndex | + socketHandle ifNotNil: [^Error signal: 'The socket is already bound']. + semaphore := Semaphore new. + readSemaphore := Semaphore new. + writeSemaphore := Semaphore new. + semaIndex := Smalltalk registerExternalObject: semaphore. + readSemaIndex := Smalltalk registerExternalObject: readSemaphore. + writeSemaIndex := Smalltalk registerExternalObject: writeSemaphore. + socketHandle := self + primSocketCreateNetwork: socketDomain + type: socketType + receiveBufferSize: 8000 + sendBufSize: 8000 + semaIndex: semaIndex + readSemaIndex: readSemaIndex + writeSemaIndex: writeSemaIndex. + socketHandle + ifNil: [ + "socket creation failed" + Smalltalk unregisterExternalObject: semaphore. + Smalltalk unregisterExternalObject: readSemaphore. + Smalltalk unregisterExternalObject: writeSemaphore. + readSemaphore := writeSemaphore := semaphore := nil ] + ifNotNil: [ self register ] \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/Socket.extension/properties.json b/repository/Zinc-HTTP-UnixSocket.package/Socket.extension/properties.json new file mode 100644 index 00000000..976f3745 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/Socket.extension/properties.json @@ -0,0 +1,3 @@ +{ + "name" : "Socket" +} \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnCannotConnectUnixSocket.class/README.md b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotConnectUnixSocket.class/README.md new file mode 100644 index 00000000..bde78879 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotConnectUnixSocket.class/README.md @@ -0,0 +1,3 @@ +ZnCannotConnectUnixSocket is signalled when a Unix Domain Socket connection should be established but was not. + +Part of Zinc HTTP Components. \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnCannotConnectUnixSocket.class/instance/file..st b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotConnectUnixSocket.class/instance/file..st new file mode 100644 index 00000000..931f68dd --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotConnectUnixSocket.class/instance/file..st @@ -0,0 +1,3 @@ +accessing +file: anObject + file := anObject \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnCannotConnectUnixSocket.class/instance/file.st b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotConnectUnixSocket.class/instance/file.st new file mode 100644 index 00000000..979743c6 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotConnectUnixSocket.class/instance/file.st @@ -0,0 +1,3 @@ +accessing +file + ^ file \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnCannotConnectUnixSocket.class/instance/messageText.st b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotConnectUnixSocket.class/instance/messageText.st new file mode 100644 index 00000000..314f5b00 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotConnectUnixSocket.class/instance/messageText.st @@ -0,0 +1,4 @@ +accessing +messageText + ^ super messageText + ifEmpty: [ self file ifNotNil: [ self file fullName ] ifNil: [ '' ] ] \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnCannotConnectUnixSocket.class/properties.json b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotConnectUnixSocket.class/properties.json new file mode 100644 index 00000000..e66afc7a --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotConnectUnixSocket.class/properties.json @@ -0,0 +1,13 @@ +{ + "commentStamp" : "", + "super" : "Error", + "category" : "Zinc-HTTP-UnixSocket-Exceptions", + "classinstvars" : [ ], + "pools" : [ ], + "classvars" : [ ], + "instvars" : [ + "file" + ], + "name" : "ZnCannotConnectUnixSocket", + "type" : "normal" +} \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnCannotCreateUnixSocket.class/README.md b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotCreateUnixSocket.class/README.md new file mode 100644 index 00000000..c13391be --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotCreateUnixSocket.class/README.md @@ -0,0 +1,3 @@ +ZnCannotCreateUnixSocket is signalled when a Unix Domain Socket should be instantiated but was not. + +Part of Zinc HTTP Components. \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnCannotCreateUnixSocket.class/instance/file..st b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotCreateUnixSocket.class/instance/file..st new file mode 100644 index 00000000..931f68dd --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotCreateUnixSocket.class/instance/file..st @@ -0,0 +1,3 @@ +accessing +file: anObject + file := anObject \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnCannotCreateUnixSocket.class/instance/file.st b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotCreateUnixSocket.class/instance/file.st new file mode 100644 index 00000000..979743c6 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotCreateUnixSocket.class/instance/file.st @@ -0,0 +1,3 @@ +accessing +file + ^ file \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnCannotCreateUnixSocket.class/instance/messageText.st b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotCreateUnixSocket.class/instance/messageText.st new file mode 100644 index 00000000..314f5b00 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotCreateUnixSocket.class/instance/messageText.st @@ -0,0 +1,4 @@ +accessing +messageText + ^ super messageText + ifEmpty: [ self file ifNotNil: [ self file fullName ] ifNil: [ '' ] ] \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnCannotCreateUnixSocket.class/properties.json b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotCreateUnixSocket.class/properties.json new file mode 100644 index 00000000..e2243e76 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnCannotCreateUnixSocket.class/properties.json @@ -0,0 +1,13 @@ +{ + "commentStamp" : "", + "super" : "Error", + "category" : "Zinc-HTTP-UnixSocket-Exceptions", + "classinstvars" : [ ], + "pools" : [ ], + "classvars" : [ ], + "instvars" : [ + "file" + ], + "name" : "ZnCannotCreateUnixSocket", + "type" : "normal" +} \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnMissingUnixSocket.class/README.md b/repository/Zinc-HTTP-UnixSocket.package/ZnMissingUnixSocket.class/README.md new file mode 100644 index 00000000..554f5aaa --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnMissingUnixSocket.class/README.md @@ -0,0 +1,3 @@ +ZnMissingUnixSocket is signalled when a Unix Domain Socket file does not exist but should exist. + +Part of Zinc HTTP Components. \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnMissingUnixSocket.class/instance/file..st b/repository/Zinc-HTTP-UnixSocket.package/ZnMissingUnixSocket.class/instance/file..st new file mode 100644 index 00000000..931f68dd --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnMissingUnixSocket.class/instance/file..st @@ -0,0 +1,3 @@ +accessing +file: anObject + file := anObject \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnMissingUnixSocket.class/instance/file.st b/repository/Zinc-HTTP-UnixSocket.package/ZnMissingUnixSocket.class/instance/file.st new file mode 100644 index 00000000..979743c6 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnMissingUnixSocket.class/instance/file.st @@ -0,0 +1,3 @@ +accessing +file + ^ file \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnMissingUnixSocket.class/instance/messageText.st b/repository/Zinc-HTTP-UnixSocket.package/ZnMissingUnixSocket.class/instance/messageText.st new file mode 100644 index 00000000..314f5b00 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnMissingUnixSocket.class/instance/messageText.st @@ -0,0 +1,4 @@ +accessing +messageText + ^ super messageText + ifEmpty: [ self file ifNotNil: [ self file fullName ] ifNil: [ '' ] ] \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnMissingUnixSocket.class/properties.json b/repository/Zinc-HTTP-UnixSocket.package/ZnMissingUnixSocket.class/properties.json new file mode 100644 index 00000000..038e6fd7 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnMissingUnixSocket.class/properties.json @@ -0,0 +1,13 @@ +{ + "commentStamp" : "", + "super" : "Error", + "category" : "Zinc-HTTP-UnixSocket-Exceptions", + "classinstvars" : [ ], + "pools" : [ ], + "classvars" : [ ], + "instvars" : [ + "file" + ], + "name" : "ZnMissingUnixSocket", + "type" : "normal" +} \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnNetworkingUtils.extension/class/socketStreamToUnixSocketFile..st b/repository/Zinc-HTTP-UnixSocket.package/ZnNetworkingUtils.extension/class/socketStreamToUnixSocketFile..st new file mode 100644 index 00000000..2eda1040 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnNetworkingUtils.extension/class/socketStreamToUnixSocketFile..st @@ -0,0 +1,4 @@ +*Zinc-HTTP-UnixSocket +socketStreamToUnixSocketFile: socketFile + ^ self default + socketStreamToUnixSocketFile: socketFile \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnNetworkingUtils.extension/instance/socketStreamToUnixSocketFile..st b/repository/Zinc-HTTP-UnixSocket.package/ZnNetworkingUtils.extension/instance/socketStreamToUnixSocketFile..st new file mode 100644 index 00000000..b6a4ef09 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnNetworkingUtils.extension/instance/socketStreamToUnixSocketFile..st @@ -0,0 +1,5 @@ +*Zinc-HTTP-UnixSocket +socketStreamToUnixSocketFile: socketFile + | ipcSocket | + ipcSocket := self unixSocketOnFile: socketFile. + ^ ZnNetworkingUtils socketStreamOn: ipcSocket. \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnNetworkingUtils.extension/instance/unixSocketOnFile..st b/repository/Zinc-HTTP-UnixSocket.package/ZnNetworkingUtils.extension/instance/unixSocketOnFile..st new file mode 100644 index 00000000..5792fdef --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnNetworkingUtils.extension/instance/unixSocketOnFile..st @@ -0,0 +1,24 @@ +*Zinc-HTTP-UnixSocket +unixSocketOnFile: socketFile + | addressSize socketAddress ipcSocket | + socketFile exists ifFalse: [ + ZnMissingUnixSocket new file: socketFile; signal ]. + + NetNameResolver + primGetAddressInfoHost: '' + service: socketFile fullName + flags: 0 + family: 1 + type: 0 + protocol: 0. + addressSize := NetNameResolver primGetAddressInfoSize. + socketAddress := SocketAddress new: addressSize withAll: 0. + NetNameResolver primGetAddressInfoResult: socketAddress. + + ipcSocket := Socket newIPC. + ipcSocket ifNil: [ + ZnCannotCreateUnixSocket new file: socketFile; signal ]. + ipcSocket connectTo: socketAddress. + ipcSocket isConnected ifFalse: [ + ZnCannotConnectUnixSocket new file: socketFile; signal ]. + ^ ipcSocket \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnNetworkingUtils.extension/properties.json b/repository/Zinc-HTTP-UnixSocket.package/ZnNetworkingUtils.extension/properties.json new file mode 100644 index 00000000..a6e89d3f --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnNetworkingUtils.extension/properties.json @@ -0,0 +1,3 @@ +{ + "name" : "ZnNetworkingUtils" +} \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnUnixSocketClient.class/README.md b/repository/Zinc-HTTP-UnixSocket.package/ZnUnixSocketClient.class/README.md new file mode 100644 index 00000000..74377bb3 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnUnixSocketClient.class/README.md @@ -0,0 +1,14 @@ +I am ZnClient. +I am ZnUnixSocketClient, an object to build, execute, and process HTTP client request over Unix Domain Sockets. + +Simplest possible invocation: + +ZnUnixSocketClient new + unixSocket: '/var/run/docker.sock'; + get: 'http://localhost/v1.43/containers/json'. + +It is equivalent to the following cURL command: + + curl --unix-socket /var/run/docker.sock http://localhost/v1.43/containers/json + +Part of Zinc HTTP Components. \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnUnixSocketClient.class/instance/newConnectionTo..st b/repository/Zinc-HTTP-UnixSocket.package/ZnUnixSocketClient.class/instance/newConnectionTo..st new file mode 100644 index 00000000..2423295e --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnUnixSocketClient.class/instance/newConnectionTo..st @@ -0,0 +1,5 @@ +private +newConnectionTo: url + self unixSocket + ifNil: [ super newConnectionTo: url ] + ifNotNil: [ :socketPath | self newConnectionToUnixSocketFile: socketPath asFileReference ] \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnUnixSocketClient.class/instance/newConnectionToUnixSocketFile..st b/repository/Zinc-HTTP-UnixSocket.package/ZnUnixSocketClient.class/instance/newConnectionToUnixSocketFile..st new file mode 100644 index 00000000..5bb781ce --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnUnixSocketClient.class/instance/newConnectionToUnixSocketFile..st @@ -0,0 +1,9 @@ +private +newConnectionToUnixSocketFile: socketFile + | initialMilliseconds | + self signalHTTPProgress: 'Connecting to ', socketFile asString. + initialMilliseconds := Time millisecondClockValue. + (connection notNil and: [ connection isConnected ]) + ifTrue: [ connection close ]. + connection := ZnNetworkingUtils socketStreamToUnixSocketFile: socketFile. + self logConnectionEstablishedTo: socketFile asZnUrl started: initialMilliseconds \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnUnixSocketClient.class/instance/unixSocket..st b/repository/Zinc-HTTP-UnixSocket.package/ZnUnixSocketClient.class/instance/unixSocket..st new file mode 100644 index 00000000..67fab110 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnUnixSocketClient.class/instance/unixSocket..st @@ -0,0 +1,3 @@ +accessing +unixSocket: socketPath + self optionAt: #unixSocket put: socketPath \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnUnixSocketClient.class/instance/unixSocket.st b/repository/Zinc-HTTP-UnixSocket.package/ZnUnixSocketClient.class/instance/unixSocket.st new file mode 100644 index 00000000..30631a77 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnUnixSocketClient.class/instance/unixSocket.st @@ -0,0 +1,3 @@ +accessing +unixSocket + ^ self optionAt: #unixSocket ifAbsent: [ nil ] \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/ZnUnixSocketClient.class/properties.json b/repository/Zinc-HTTP-UnixSocket.package/ZnUnixSocketClient.class/properties.json new file mode 100644 index 00000000..17d0ad27 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/ZnUnixSocketClient.class/properties.json @@ -0,0 +1,11 @@ +{ + "commentStamp" : "", + "super" : "ZnClient", + "category" : "Zinc-HTTP-UnixSocket-Client-Server", + "classinstvars" : [ ], + "pools" : [ ], + "classvars" : [ ], + "instvars" : [ ], + "name" : "ZnUnixSocketClient", + "type" : "normal" +} \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/monticello.meta/categories.st b/repository/Zinc-HTTP-UnixSocket.package/monticello.meta/categories.st new file mode 100644 index 00000000..ae7899a7 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/monticello.meta/categories.st @@ -0,0 +1,3 @@ +SystemOrganization addCategory: #'Zinc-HTTP-UnixSocket'! +SystemOrganization addCategory: #'Zinc-HTTP-UnixSocket-Client-Server'! +SystemOrganization addCategory: #'Zinc-HTTP-UnixSocket-Exceptions'! diff --git a/repository/Zinc-HTTP-UnixSocket.package/monticello.meta/initializers.st b/repository/Zinc-HTTP-UnixSocket.package/monticello.meta/initializers.st new file mode 100644 index 00000000..e69de29b diff --git a/repository/Zinc-HTTP-UnixSocket.package/monticello.meta/package b/repository/Zinc-HTTP-UnixSocket.package/monticello.meta/package new file mode 100644 index 00000000..73bd3b28 --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/monticello.meta/package @@ -0,0 +1 @@ +(name 'Zinc-HTTP-UnixSocket') \ No newline at end of file diff --git a/repository/Zinc-HTTP-UnixSocket.package/properties.json b/repository/Zinc-HTTP-UnixSocket.package/properties.json new file mode 100644 index 00000000..6f31cf5a --- /dev/null +++ b/repository/Zinc-HTTP-UnixSocket.package/properties.json @@ -0,0 +1 @@ +{ } \ No newline at end of file